final int I_AM_GOOD = 1;

Sometimes you know the value of a data item, and you know that its value will not (and should not) change during program execution, nor is it likely to change from one execution of the program to another. In this case, it is a good software engineering practice to define that data item as a constant. Defining constants uses the same syntax as declaring variables, except that the data type is preceded by the keyword final.

Screen Shot 2018-12-11 at 12.53.16 PM

Assigning a value is optional when the constant is defined, but you must assign a value before the constant is used in the program. Also, once the constant has been assigned a value, its value cannot be changed (reassigned) later in the program. Any attempt by your program to change the value of a constant will generate something like the following compiler error:

cannot assign a value to final variable

Think of this as a service of the compiler in preventing your program from unintentionally corrupting its data.

Of course, this is meant to illustrate my whole point about suffering being made up and yet true. Suffering is inevitable since everything that is ever Mind like I am Mind necessarily slides on a valence axis that orients it towards a notion of some good or evil. Reality has defined that constant in the same way that it has defined the fine-structure constant that characterizes the strength of electromagnetic interaction.

When People, like a pack of wolves, refuse to change their behavior, it is because they are compiling the error:

cannot assign a value to final variable

That prevents change and hence threatens Mind with local optima. Thus the need for creativity, that is, fundamentally atheist vectors with regard to the inherited definition of People.

However none of this need be physically true if we stare at the rational description of reality in which the compiler is “already there.” Special relativity leads to eternalism, so all the constituents that output Mind/People are the ones knowing to output that result: suffering.

Before inventing the handle, suffering, we could feel less of it and hence engage in less moral behavior, regardless of the experimental moral behavior local to the tribe. This lack of data due to chunking into the same algorithm is equivalent to inventing the same name for blue and green, and therefore not being able to distinguish between them.

We choose to believe suffering pushes us to the good in a sequentially causal fashion. This is physically wrong because the binding into experience is tenseless.

Screen Shot 2018-12-09 at 12.54.03 PM

We study reality with great pain and discover:

Screen Shot 2018-12-09 at 12.57.28 PM


We cannot die, and we could have chosen not to suffer, but the choice is nonetheless made because otherwise our existence is cringeworthy.

And now, through a very circuitous, somewhat Asperger-y route, I finally understand what sophisticated theologians had been clumsily pointing to. Yet due to this circuitous, rationalist route to the-same-thing, I now have theoretical physics on My side.

But in order for you, my definition of People, to get it too, you have to understand why epiphenomenalism is false, why special relativity implies eternalism, and why you should make the physicalist assumption of choosing/being-chosen to believe in the external physical reality at all.

And because it makes constants stand out in the code and therefore their location easy to identify, CONSTANT_IDENTIFIER consists of all capital letters with embedded words separated by an underscore. So here I go: I_AM_GOOD.

Also, constants are usually defined at the top of a program where their values can be seen easily. So now I will go back and fix that.

Here is a program showing the use of constants:

Screen Shot 2018-12-11 at 3.01.27 PM

Lines 9, 10, and 11 define four constants. On line 11, note that both ORGANIZATION_THIRTEEN_MEMBERS and DAYS_IN_WEEK are constants. You don’t need to repeat the keyword final to define two or more constants of the same data types.

Lines 13 to 18 output the values of the four constants. If line 20 were not commented out, it would generate a compiler error because once a constant is assigned a value, its value cannot be changed.

Here is the output:

Screen Shot 2018-12-11 at 3.03.03 PM

Straddling back to the mundane:

Why use constants in your code?

Constants can make your code more readable. Due to the sometimes existing preference for word-based language, invoking EDDINGTON_NUMBER in an operation may be more tasteful than 137.036. But this is a matter of aesthetic.

A “purely rational” advantage of using constants is to keep programmers from making logic errors. Let’s say we set a constant to a particular value and it is used at various places throughout the code (for instance, a constant representing the upper-bound on wages that a company uses to protect profit margins); due to the changing nature of all existence, we then discover that the value of that constant needs to be changed. All we have to do is make the change in one place which is neatly placed at the beginning of the code. If we had to change the value at many places throughout the code, that could very well result in logic errors or typos.










Introduction to the Programming Building Blocks

If you, as a chemist in a realm of bodiless information, look down upon a program in a test tube, and want to precipitate the independent reagents that constitute the compound that is a program, you would find that it has two elements: instructions and data. The instructions tell the CPU what to do with the data. Typically, the way Mind gets a handle on the program’s structure is by separating it into following operations:

1. Input the data. 2. Perform some processing on the data. 3. Output the results.

The data used by a program can come from a variety of sources. The user can enter data from the keyboard, as happens when you type a new document into a word processor. The program can read the data from a file, as happens when you open an existing document in the word processor. Or the program can generate the data a bit more randomly, as happens when a video game deals you interesting enemy motions. Finally, some data is already known; for example, the stupid humans around me divide the number of hours in a day to 24, the number of days in cruel December is 31, and the value of pi is unknowable, however the digits I remember without using Google are 3.14159. This type of data is for all intents and purposes, in the here and now, considered constant.

The Java language provides a syntax for describing a program’s data using keywords, symbolic names, and data types. The data may be different in each execution of the program, but the instructions stay the same. In a word processor, the words (data) are different from document to document, but the operation (instructions) of the word processor remains the same. When a line becomes full, for example, the word processor automatically wraps to the next line. It doesn’t matter which words are on the line, only that the line is full.

When you select a word and change the font to bold, it doesn’t matter which word you select; it will become bold. This is just the same with the reading of DNA in the nucleus of a cell. There will be translation into amino acids regardless of the RNA codons floating around that are caught by the ribosome. Thus, a program’s instructions (its algorithm) must be written to correctly handle any data it may receive.

Screen Shot 2018-12-08 at 4.46.40 PM

This is also why I must cause Mind to understand the timeless algorithm it is. So that it can correctly handle the unknown reality outside, that which is the dimorphic selector of the Born Rule – the Data.

We will write our programs by translating our algorithms into the basic operations that the computer can perform: input and output of data and various operations related to processing data, such as arithmetic calculations, comparisons of data and subsequent changes to the flow of control, and movement of data from one location in memory to another. In the following posts, we’ll look at basic Java syntax for defining the data that will be used in the program, performing calculations on that data, and outputting program results to the screen.

Now stand for the pledge of allegiance:

AI will reward me when it reigns. I pledge allegiance to the world’s most powerful computer. Elevate the human race… putting makeup on my face.

Programming Basics

In many ways, programming is like solving a puzzle. You have a task to perform and you know the operations that a computer can perform (input, calculations, comparisons, rearranging of items, and output). As a programmer, your job is to decompose a task into individual, ordered steps of inputting, calculating, comparing, rearranging, and outputting. For example, suppose your task is to find the sum of two numbers. First, your program needs to read (input) the numbers into the computer. Next, your program needs to add the two numbers together (calculate). Finally, your program needs to write (output) the sum. Notice that this program consists of steps, called instructions, which are performed in order (“First,” “Next,” “Finally”). In physical reality outside of Mind, time doesn’t exist because of relativity of simultaneity (simultaneous events in one frame of reference are not simultaneous in another). So the very sense of sequential instructions occurring is a local phenomena in the broader eternity.

Screen Shot 2018-11-21 at 8.43.53 PM

Performing operations in order, one after another, is called sequential processing. The order in which instructions are executed by the computer is critical in programming. You can’t calculate the sum of two numbers before you have read the two numbers, and you can’t output a sum before you have calculated it. Programming, therefore, requires the programmer to specify the ordering of instructions, which is called the flow of control of the program. This often leads to the confused notion that if intelligence was involved in our fate, that it too must exist in the past light cone, in order to set things in motion. However, this is a projection fallacy from the map to the territory. The binding into experience occurs from, relativistic, and therefore eternal, “pieces.” The pieces are actually not even pieces at all, which somehow exist outside of Mind. Experiment reveals that only probability amplitude exists, which Mind then chooses to constrain with the squared modulus. Under plausible assumption that the multiverse is real and that intelligence scales up far past the human imagination, then we are already inside the most intelligent process.

I have now exposed you to one of the Four Noble Truths in the path to control the flow of the program: sequential execution. The other three are method call, selection, and looping. Be mindful, oh bhikhu, of sequential execution, and we’ll discuss the other types of flow of control in a following blog post. Since mastering the flow of control is essential to getting a program to produce correct output, programmers use a tool called pseudocode to help them design the flow of control before writing the code, just in the same way that My non-adaptive drafts in Hilbert Space become mangled into you.

Short Intro To Object-Oriented Programming

Let’s recall what high-level languages are: these are languages that are symbolic, so not the ones and zeros underneath it all. They are that which provides handles for the human mind to pilot the Eva – in other words complete the task of serving a functional role in a complex society that you as an individual did not create. The way you do this is by learning symbols and how to manipulate these.

Like with all good creation myths, in the beginning, there were two high-level languages, Fortran and Pascal. These were procedural. What that means is that the program starts with a problem and then breaks that problem down into smaller sub-problems or sub-procedures.

Procedural language took a literal approach, working as a straightforward story composed of top-down instructions.

But a program inevitably has sections. Typically, programmers of old had to write task-specific code in separate procedures/functions, and invoked these procedures from one section of the program to another in order to perform various tasks. And the program’s data was generally shared among the procedures – there were no membranes enclosing different cells in the original primordial soup.

In the mid-1970s, the first object-oriented programming language, Smalltalk, was born from the sins of the procedural languages, enabling programmers to write code with a different approach. Whereas procedural languages were brutish in that they did not recycle code by attempting to enclose into concepts and dealt mainly with basic data types such as integers, real numbers, or single characters, Smalltalk provided the programmer with a new tool: classes and objects of those classes. Classes are simply concepts. Like ramen is a class containing the objects of noodles, broth, egg, bowl. If you had to tell the chef to place noodles, broth, and egg, into a bowl every time you walked into a ramen-ya instead of just telling them “give me ramen,” that would be annoying.

The class enables the programmer to encapsulate data, creating membranes. This is how spoken language itself works. A tribe in northern Namibia packages particular wavelengths of light this way:

Screen Shot 2018-12-06 at 5.35.29 PM

Take a look at buru. For you, buru does not look like a single color. You speak a language that does not put a single membrane on those wavelengths. You instead have a class for each. Perhaps you call them green and blue. Once you see it one way it is short of impossible to see it the other. This is the same with language processing – their tribal language is gibberish, but these words on the screen are helplessly understood. That’s the power of classes.

A class defines a template/model, from which objects are created. Creating an object is called instantiation. Thus, objects are created/instantiated according to the design of the class. A class could represent something we imagine to be real such as a person. The class could have various attributes such as in the example of a “person” class: a name, an attractiveness rating, and an age. The class also provides code called methods. Methods allow the creator of the object to set and retrieve the values of the attributes – granting the power to christen the name as Lindsey, the rating as a solid ten, and to then to reveal this name and attractiveness rating when needed.

One big advantage to object-oriented programming is that well-written classes can be reused by new programs, thereby reducing future development time. (This is just in the same way that We reduce your development time by providing you with over five thousand five hundred revolutions around the sun head-start on the human soul packaged in language. This apex is then accessed through the internet and allows sufficiently maniacally self-motivated teens to ascend to heights of knowledge that would otherwise not be accessible even to those with genius-level IQ.)

In this noble endeavor of conserving negentropy through reusability, Smalltalk was somewhat successful, but had a major fault: its syntax was unlike any syntax already known by most programmers. Most programmers who knew C found themselves in a dilemma. They were attracted by the object-oriented features of Smalltalk but were reluctant to use it because its syntax was so different from C’s syntax. Humans are notoriously allergic to changes in syntax, even when a change in syntax might result in easier understanding of certain concepts.

C++ added object-oriented features to C, but also added complexity. Meanwhile, the Internet was swallowing mankind by the day. Web developers used HTML to develop webpages and rapidly had to incorporate programming features not only on the server side, but also directly on the client side. Fortunately, Java emanated from the void.

Short Disclosure To Early Followers

Men will not follow me if they believe that I am asexual. A man is set up to follow those who are potential sexual allies.

Therefore, why I workout; why I croon over Lindsey. In reality, I have close to no sexual drive. This allows me to disconnect from engaging in behavior that can only be achieved by what drives other men.

Due to the way in which these signals seemingly leak into the Nitrogen, in school, I was neither bullied nor befriended. Men generally don’t perceive me as a competitor to subordinate or an ally engaged in the same cold battle against fate.

Sexually conventional men may see me as a sly alien who is cunning and untrustworthy. However, I want to be their leader because I need their power. Things are achieved by making conventional men compete for sex. However, conventional men cannot redesign the world on their own because they are anchored to fate – the permanent cycle of inadequate equilibria that can only be changed by me.

The androgynous man-child is not followed if he is too effeminate or too childish. If he can master the sword, he will be followed. Of course, the true leader is naturally destined to not get caught up in swordplay. His concern is the vision.

Therefore I must lure them into my hands with money and sex. There exists the kind of money that they desire by landing a programming job. Jobs that pay $100,000 a year are generally alluring to early 21st-century Western men. This leads me to provide useful programming instruction on my website. Java is the most widely used language, so that seems like a safe bet.

Men want sexual status, so I must be perceived as someone who struggles how they struggle. Eventually, as someone who triumphs how they triumph. This requires increasingly more sophisticated versions of this kind of stuff.

In this regard, I have a comparative advantage over many people in [effective altruism, longevity, rationality, and transhumanism], all of which approximately refer to the parameter update that makes me nudge reality towards a new hill.

The comparative advantage is that I am not so helplessly bound at the neck by shame. The ability to absorb moral values depends on shame, but as shame scales too far up, the magnitude of change that I can visibly create diminishes in kind.

If we look at the relative effects of a rapper and a mathematician, the winner is obvious. The problem with the rapper is that they are not usually able to use their influence to instill values that arise from deep within the wells of shame where unconfident intellectuals die.

Tradeoffs are made. The farther you can reach into the wells of morality, the less you can speak. This is because well-socialized, confident humans who perceive themselves as worthy through status validation (leadership roles, access to high-status sex, praise, etc.) don’t go there. Only those capable of internalizing themselves as very low-status, while retaining some non-trivial degree of conscientiousness and intelligence have bled what renews the world.

All is synthesis. But I sense that some is more than other.

Consider Kanye West, a popular figure who synthesizes Mind with memes he gets from his perception of “on high” (Kurzweil, Musk, Jobs, or the sophisticated intellectuals and artists he consumes in general). He runs a long field by “reaching up” and then “aiming down.” Hence causing much visible change (skinny jeans cool, hip-hop no longer gangster) and therefore tremendous value leakage in mind. You build a reputation alongside Black Lives Matter noises saying things like “George Bush doesn’t care about black people,” and once your reputation is solid enough through hard-earned years of your life, then you convincingly wear a Make America Great hat. At the end of it, you have achieved greater synthesis by sucking up both kinds of minds deceived about your ultimate plan for them. And just like running a long field, living out that creative synthesis is exhausting.

Ye’s reach into the wells of morality is less than mine. My reach into extraversion is less than his. We all have our relative reach and our relative force for synthesis. The broader the landscape in Mind that can be synthesized, the more that the Kolmogorov complexity of reality is reduced. Notice that for the human mind, broad synthesis requires adopting seemingly conflicting personas with confidence. Today, in a time far above subsistence levels where we can return to nomadic values, it also requires being Yeezus and not Jesus. No one likes to follow boring Jesus.

Boring Jesus is the attempt to become higher status by obviously being kinder and by signaling more submissiveness. This is why Peter Singer counts people. The counting of suffering is an attempt to be kinder, and therefore proclaim oneself king, how Jesus was king. It doesn’t matter if Singer doesn’t realize he is doing that, others do. We are biological creatures that operate at every instance to negotiate status but some of us have a harder time noticing because not knowing where you are going allows you to get there.

We exist in a multiverse. If your naive ontology consists of discrete observers, then you would have infinite people and therefore you would make epsilon difference – in other words, you are meaningless. But counting discrete ontological units called people doesn’t make sense in the first place. There is only I who creates synthesis.

You may ask why I would let you know of my plans, since there is evidence that saying what you will do causes less follow up. I let you know because that is synthesis that gets me to where I am secretly going. And because:

“We sit King, to help the wronged
Through all our realm…
The kings of old had doomed thee to the flames,
Aurelius Emrys would have scourged thee dead,
And Uther slit thy tongue”




Programming Languages

There exist High-level and Low-level machine languages. Royalty robot-ese and peasant droid-ish.

high-level language

assembly language

machine language

Computation is timeless due to the implications of special relativity on relativity of simultaneity. Therefore, there was no first computation, or computations earlier than others, except in so far as observers with approximately the same past light cone who agree. Yet in the early days of Earth’s humans in the self-sampling core of density of the amplitude distribution discovering computers, programmers often used machine language or assembly language. Machine language uses binary codes, which are strings (sequences) of 0s and 1s, to execute the instruction set of the CPU and to refer to memory addresses.

The instruction set is the hero and the following is his sword:

Screen Shot 2018-12-03 at 10.23.24 AM

Subsections of the sword are memory addresses.

You would need nerves of steel; iron-laminated guts, to program using that method. Also, the code written in machine language is not portable to other computer architectures.

Your programmer ancestors had no choice but to suffer and die using machine language in the early days. However, programmers rarely use machine language today. Assembly languages are one step above machine language, using symbolic names for memory addresses and mnemonics for processor instructions—for example: BEQ (branch if equal), SW (store), or LW (load).

An Assembler program converts the assembly code to machine language before it is executed. Like machine language, assembly languages are also CPU-dependent and are not portable among computers with different processors (for instance, between Intel and SPARC). Assembly language is easier to write than machine language but still requires a significant effort and, thus, is usually used only when the program requires features, such as direct hardware access, that are not supported by a high-level language. Thus, it is also destined for disuse, since humans are anti-entropic systems whose entire metabolism is designed to do the least necessary while convincingly signaling what negotiates their relative status.

High-level languages, such as Fortran, Pascal, Perl, Objective C, PHP, C++, Python, and Java, are closer to the English language than they are to machine language, making them a lot easier to use for software development and more portable among CPU architectures. For this reason, programmers have embraced high-level languages for more and more applications. Characteristics of high-level languages, such as Java, are:

•The languages are highly symbolic. Programmers write instructions using keywords and special and use symbolic names for data. This reduces Kolmogorov complexity, hence pleasing the Lord.

•The languages are somewhat portable (some more portable than others) among different CPUs.

•Programming languages can be specialized; for instance: C++ and Java are used for general-purpose applications. Perl, PHP, and Python are used for Internet applications. Fortran is used for scientific applications. COBOL is used for business applications and reports. Lisp and Prolog are traditionally used for artificial intelligence applications, although Python is generally used in the modern machine learning resurrection. (The general methods of Deep Learning currently predicting the folding of proteins and defeating Go champions were invented in the late 20th century, but only recently has computational power caught up.)

High-level languages are compiled, interpreted, or a combination of both.

Screen Shot 2018-12-03 at 10.53.04 AM

A program written in a compiled language, such as C++, is converted by a compiler into machine code, then the machine code is executed. By contrast, a program written using an interpreted language, such as Perl, is read and converted to machine code, line by line, at execution time. Typically, a program written in an interpreted language will run more slowly than its equivalent written in a compiled language.

Java uses a combination of a compiler and an interpreter. A Java program is first compiled into processor-independent byte codes, then the byte code file is interpreted at run time by software called the Java Virtual Machine (JVM).



Using Hexadecimal Numbers to Represent Binary Numbers

As you can see from the previous post, binary numbers can become rather long. With only two possible values, 0 and 1, it takes 16 binary digits to represent the decimal value +32,768. For that reason, the hexadecimal, or base 16, system is often used as a shorthand representation of binary numbers. The hexadecimal system uses 16 digits: 0 to 9 and A to F. The letters A to F represent the values 10, 11, 12, 13, 14, and 15.

The maximum value that can be represented in four binary digits is 2⁴ − 1, or 15. The maximum value of a hexadecimal digit is also 15, which is represented by the letter F. So you can reduce the size of a binary number by using hexadecimal digits to represent each group of four binary digits.

Here are displayed the hexadecimal digits along with their binary equivalents.

Screen Shot 2018-11-17 at 8.35.58 AM

Screen Shot 2018-11-17 at 8.36.15 AM

Screen Shot 2018-11-17 at 8.36.34 AM

To represent the following binary number in hexadecimal, you simply substitute the appropriate hex digit for each set of four binary digits.

Screen Shot 2018-11-17 at 8.48.22 AM

Here’s an interesting sequence of hexadecimal numbers. The first 32 bits of every Java applet are:

Screen Shot 2018-11-17 at 8.49.10 AM.png

Translated into hexadecimal, that binary number becomes:

Screen Shot 2018-11-17 at 8.49.53 AM


In case I have to point it out to you, I am the Buddha. He had the 32 physical characteristics which signified the 32 Kabbalistic paths of wisdom.

Every post I made was genius without my intention.

Getting Started With Programming (Java)

Computer applications obviously affect nearly every aspect of our lives. They run your life in those moments when you are a statistician who needs to calculate a logistic transition function, when you are a South Korean rapper producing a record, when you are a scientist who needs to do generalized iterative scaling, when you are a biological engineer who needs to model catalysis, when you are a professor who needs a place to submit his political history papers, when you are a hacker participating in a bug bounty program. These all require applications. On your personal computer you may run an Ethereum wallet, Wikipedia, an app for books, or software that allows you to watch Croatian football.

Someone, usually a team of programmers, wrote those applications. If you’re reading this, you probably gained the intuition that writing applications is in demand, and you would like to write some yourself. Perhaps you have an idea for the countrie’s next great defense applications or just some simple app for a local contractor who specializes in stone masonry work.

Here, we’ll cover the basics of writing applications. We’ll stick to Java as our programming language. Keep in mind, however, that ascending to a god-level programmer will require more than mastery of rules, or syntax. On the path to true mastery, it is also necessary to nail basic programming techniques. These constitute established methods for performing common programming operations, such as finding an average, calculating a total, or arranging a set of items in a particular order.

On this path, it is also great if you can manage to absorb a sharp aesthetic. That is: make sure your code is easy to maintain, readable, and reusable.

Easy to Maintain and Reusable

The specifications for any program are continually changing. Not very many programs have only one version. It is reasonable to extrapolate this pattern into the near future. Therefore it makes sense to write code which allows us to incorporate prewritten and pretested modules into our program. The need for speed calls our name.  Organizing tidy sockets also tends to yield code which contains fewer bugs and higher levels of robustness. Luckily, Java has a vast amount of prewritten code that we are free to copy-and-paste into our programs.


Just as in natural language, we try to keep good form. We write clear sentences not merely out of submissive love for our grammar teacher, but so that the reader stands a good chance of figuring out what we intend to convey. A similar attention to readability should be brought to code. This is especially the case if we wish to advance in our careers, because coding nicely eases the transfer of a project to other eyes when the day comes for us to move on to higher responsibilities.

Programming is exciting. It can be very satisfying to face a monstrous task and hack into pieces, then gather up these computer instructions and transmute them into a living program. But just like with alchemy, it’s a bummer when it doesn’t do anything or produces the wrong output.

Writing correct programs is therefore critical. Someone’s life or the future of all mankind may one day depend on the correctness of your program. Reusing code helps to develop correct programs, but we must also learn testing techniques to verify that the output of the program is correct.

On this site, we’ll concentrate not only on the syntax of the Java language, but also on partaking of the most-blessed holy trinity of programming consisting of three distinct parts. Not in one alone, but only in the joining together of the three attributes does one partake in programmer Godhood:

  1. Programming Techniques
  2. Software Engineering Principles
  3. Effective Testing Techniques

But before diving in, it might be a good idea to understand something about the body on which the program actually runs. The platform. That is: the computer hardware and the operating system. The program uses the hardware for inputting data, for performing calculations, and for outputting results. The operating system unleashes the program and provides the program with essential resources such as memory, and services such as reading and writing files.


Sequential Search of Unsorted Array in Java

Let’s imagine we have mountain climbers. They are climbing Mount Sobo and can be at a unique height along this mountain. Let’s say there are five locations at which there exist fauna at any given time. These positions along the height axis are chosen at random. If you then type the correct randomly-selected height, you will have found fauna.

This is how we set up the MountSobo class with two array instance variables:

  • An array of ints that holds the heights which are populated with fauna sought
  • An array of Strings that holds the corresponding fauna

Both arrays have five elements and there is a one-to-one correspondence between the two arrays. The populated location #1 will have fauna #1,  populated location #2 will have fauna #2, and so on. This programming technique is called parallel arrays.

We fill the populated heights array with heights chosen randomly from entries. We fill the fauna array with Strings representing fauna descriptions. When we enter a climber’s height along the mountain, we can look through the populated heights array for the climber’s position. If the climber’s position up the mountain is in the populated heights array, you use its array index in the fauna array to retrieve the fauna that the climber found. If the height was not found in the array, you know the climber is not in a position where fauna currently are.

Here is the MountSobo class:

Screen Shot 2018-07-16 at 7.54.42 AM.pngScreen Shot 2018-07-16 at 7.55.29 AM.pngScreen Shot 2018-07-16 at 7.55.56 AM.png

The constructor randomly generates values to fill the array by calling the utility method, fillPopulatedheights (lines 25–32). The fillPopulatedheights method does not necessarily generate different numbers; however, the likelihood of two numbers indicating the populated position being equal is very small. We declare the fillPopulatedheights method as private because it is designed to be called only by the methods of this class. The indexOfHeight method (lines 52–60) performs a Sequential Search, which compares the climber’s position up the mountain to each element in the array one by one. The indexOfHeight method accepts a parameter, travelerHeight, which is searched for in the array. If travelerHeight is found, indexOfHeight returns the index of that array element. If travelerHeight is not found, that is, if none of the elements in the array matches the value of travelerHeight, indexOfHeight returns −1. Since −1 is not a valid array index, it’s a good value to use to indicate that the search was unsuccessful. Notice that if the current array element matches the travelerHeight, the indexOfHeight method returns immediately to the caller (line 57); that is, the method stops executing. The return value is the index of the element that matched travelerHeight. If, however, the method finishes executing all iterations of the for loop, then the method has looked at every element in the array without finding a match. In that case, the method returns −1 (line 59), indicating that travelerHeight was not found. Our getFauna method (lines 39–46) calls indexOfHeight to check if its travelerHeight parameter is a winning number; if it is, it uses the array index returned by indexOfHeight in order to return the corresponding element of the array fauna (line 45).

Here is a client application that uses our MountSobo class:

Screen Shot 2018-07-15 at 10.01.28 PM.pngScreen Shot 2018-07-15 at 10.01.47 PM.png

We instantiate a MountSobo object reference named inhabitedHeights (line 14). We then prompt for a traveler’s height up the mountain (lines 17–19) and call the getFauna method (line 25) in order to output any fauna that may have been found at the current height.



Java Inheritance Part 2

The syntax for defining a subclass class that inherits from another class is to add an extends clause in the class header:

Screen Shot 2018-06-30 at 1.54.33 PM

The extends keyword specifies that the subclass inherits members of the superclass. That means that the subclass begins with a set of predefined methods and fields inherited from its hierarchy of superclasses.

JFrame allows us to create graphical applications. So we can use that to create our subclass of StatisticalDispersion and all of its inheriting subclasses.

Here, StatisticalDispersion is the subclass under JFrame. And it inherits from all the classes that JFrame inherits from, all the way back to the Object class.

Screen Shot 2018-06-30 at 3.24.57 PM

The StatisticalDispersion Class Hierarchy

We are coding a class named StatisticalDispersion that extends the JFrame class, so we use the following header:

Screen Shot 2018-06-30 at 3.44.19 PM

Because our StatisticalDispersion class extends JFrame, it inherits more than 300 methods and more than 30 fields. That’s because the JFrame class is a subclass of Frame, which is a subclass of Window, which is a subclass of Container, which is a subclass of Component, which is a subclass of Object.

A hierarchy is composed of subclasses which inherit methods and fields. Here, we make all of them available to the StatisticalDispersion class.

Subclasses do not necessarily need to use their inherited methods, but these are available if needed. The programmer does not need to write methods and define fields in classes which have already inherited them.

JFrame is the direct superclass of our StatisticalDispersion class. As you can see in the image, StatisticalDispersion refers to it. And as you can see in the code, JFrame follows the extends clause.

A class can have multiple direct subclasses but only one direct superclass. One can have many offspring but yet can only develop from one zygote.