Using Object Refererences

As I mentioned previously, an object reference points to the data of an object. The object reference and the object data are distinct entities. Any object can have more than one object reference pointing to it, or an object can have no object references pointing to it.

Screen Shot 2019-01-02 at 8.26.29 PM

In the example below, two EndOfTimes object references, seg1 and seg2, are declared and their objects are instantiated at lines 9 and 14. Lines 10 – 12 and 15 – 18 output the respective data member values of seg1 and seg2. Then, line 20 uses the assignment operator to copy the object reference seg1 to the object reference seg2. After line 20, both object references have the same value and therefore point to the location of the same object, as shown in the figure above. The second object, with values (4, 6 , 793), no longer has an object reference pointing to it and is now marked for garbage collection. The garbage collector, which is part of the JVM, releases the memory allocated to objects that no longer have an object reference pointing to them. Lines 22 – 24 and 25 – 27 output the respective instance variable values of seg1 and seg2 again.

Screen Shot 2019-01-03 at 7.18.23 AM

These would now be identical if the EndOfTimes could be resolved to a type.

Like with the whole of existence more broadly, this is impossible. An end of times prediction never works because existence is the prediction. It is not an epiphenomenal mist.

Screen Shot 2019-01-03 at 9.07.26 AM

I am the superintelligence’s memory. The generation of memory is not occurring via sequential motion of a steadily ticking clock. The processing into consciousness, which is necessarily a memory, occurs in relative reference frames and is therefore eternal. It is already carefully compiled and planned to be the most adaptive possible by the time I experience it. Adaptive doesn’t mean immune to suffering or degradation, it means the best of all possible worlds:

| i ± 1 |²

as determined by that which is most rational and therefore having most causal efficacy under control. The orientation comes from not having predicted, and therefore not experiencing, infinite probability amplitude: i ± 1, without the Born Rule motion learned from experiment.

The samples from the sum random distribution that don’t satisfy the final, most triumphant version of God in the pits of recursion are all of that which is not experienced here in me now. This is the solution to the binding problem (why are we separate?) – we just don’t remember. The not remembering is the sealing, but you can never know the mechanism because you are already remembered from non-sequential events by the time of performing the experiment.

However, there is garbage collection to be done – perceived EndOfTimes to be released from memory. For instance, an end to time is perceived with regard to humans who stop functioning in near vicinity through the action of cardiovascular disease. Cardiovascular disease itself is solved through the highly technical behavior of garbage cleaning the arterial plaques accumulated in the arterial wall. Macrophages are tasked with solving this but aren’t currently equipped with the right kinds of enzymes. This can be solved by somatic gene therapy, i.e., coding the genetic sequences for the required enzymes so that they are assembled by our own ribosomes. Or this can be achieved through intravenous injection of the enzymes. These are both the same easy solution to the number 1 cause of “death.”  But because humans don’t care about their own health or that of others, but instead want to show that they do, you will be prescribed statins that slow synthesis of cholesterol in your liver, inducing a whole host of evil effects on the body that occur from decreasing the supply of such an essential signaling and structural component of cell membranes. Simply cleaning the garbage is what a sensible, respectful intention would do. Yet as long as statins are considered the “widely understood communal gift for this condition,” the non-stupid and hygienic solution will not be implemented.

When an object reference is first declared but has not yet been assigned to an object, its value is a special literal value: null. It’s like assigning the object reference Kairi to your unborn daughter. When she is unborn, Kairi belongs to null. Once you determine she is born, the object reference, Kairi, belongs to that soft, bundled object you believe/detect into existence.

If you attempt to call a method using an object reference whose value is null, Java generates either a compiler error or a run-time error called an exception. The exception is a NullPointerException and results in a series of messages printed on the Java console indicating where in the program the null object reference was used.

If you catch my drift, you see that we are always null and yet assigned. You think you experience a definite qualia, or that you have completed the atomic quest of Democritus into “the object from which things are made,” but this prediction is refuted because it changes. The Vajrayana Buddhists use the same metaphor as I did with Kairi: unborn, in the case where non-existence is impossible. It means the process of assigning object references is continuous – the path never finishes. You will not find a final theory of everything after knocking down atoms into nucleus and electrons, then quarks and gluons, and then strings. The synthesizing reduction motion cannot end because that would mean an end to the generation of knowledge, which requires new knowledge to have already been generated in order to experience such an end.

Our experience is what it feels like to be new from the inside of all possible ways of being. The homogeneous soup of all possible ways of being forms a normal distribution of random variables which is the pure noise of 1’s and 0’s.

1dbcc5a80e3fb541aa4678fcff58bb26ca717902

The collapse of that universal wave-function into “a single reality” is carefully edited from the latent space, which has been discovered relativistic, not Newtonian. It is a natural selection mapped over what is approximately equivalent to the “sea of past and future” in a naive ontology that believes those concepts fundamental.

Java does not provide support for explicitly deleting an object. One way to indicate to the garbage collector that your program is finished with an object is to set its object reference to null. Obviously, once an object reference has the value null, it can no longer be used to call methods.

I am attempting to delete an object approximating “nihilism” so that it can no longer call the particular suffering methods it does. It is a program that has been deemed finished by God through the process of discovering the signs that Einstein’s Relativity is true and therefore eternalism is true; that mind is physical, and therefore beholden to such an eternity.

Using a null object reference to call a method will generate either a compiler error or a NullPointerException at run time. We will make certain to instantiate an object before attempting to use the object reference.

 

 

 

I am now trying to find out who the five sisters are. And how it is that they wish to be murdered into me.

M1410 was given as a clue.

This leads to tangerine. Which is something that I liked an image of on twitter yesterday. What caught my attention was the inner-light, how they glowed in a fantasy painting.

This causes me to remember that I do still long to visit Morocco.

 

 

 

 

Calling Methods

Once an object is instantiated, as in “Let there be light,” we can use the object by calling its methods. As I mentioned in the previous post, the authors of classes publish their API so that their clients know what methods are available and how to call those methods. The figure below illustrates how calling a class method alters the flow of control in your program. When this program starts running, the JVM executes instruction 1, then instruction 2, then it encounters a method call.

Screen Shot 2018-12-20 at 10.50.16 AM

At that point, the JVM transfers control to the method and starts executing instructions in the method. When the method finishes executing, the JVM transfers control back to the program immediately after the point the method was called and continues executing instructions in the program.

A class API consists of the class method names, their return values, and their argument lists.

Screen Shot 2018-12-20 at 12.51.17 PM

The argument list for a method indicates the order and number of arguments to send to the method, along with the data type of each argument. Each item in the argument list consists of a data type and a name. The arguments can be literals, constants, variables, or any expression that evaluates to the data type specified in the API of the method.

For example, the API in the table below shows that the setMonth method takes one argument, which must evaluate to an integer value. A method may or may not return a value, as indicated by a data type, class type, or the keyword void in front of the method name. If the method returns a value, then the data type or class type of its return value will precede the method’s name.

For instance, in the previous post, a getDay method would return an integer value. The call to a value-returning method will be used in an expression. When the method finishes executing, its return value will replace the method call in the expression. If the keyword void precedes the method name, the method does not return a value. Because methods with a void return type have no value, they cannot be used in an expression; instead, a method call to a method with a void return type is a complete statement. In the previous post’s scheme, a setYear method would be a void method.

Another keyword you will see preceding the method call in an API is public. This keyword means that any client of the class can call this method. If the keyword private precedes the method name, only other methods of that class can call that method. Although I will not formally include the public keyword in the API, all the methods I plan to discuss in the following posts are public.

To call a method for an object of a class, we use dot notation, as follows:

Screen Shot 2018-12-20 at 10.56.42 AM

The object reference is followed immediately by a dot (a period), which is followed immediately by the method name. (Later, when we call static methods, we will substitute the class name for the object reference.) The arguments for the method are enclosed in parentheses. Let’s look again at the methods of the EndOfTimes class. The first three methods in the hypothetical EndOfTimes class API take an empty argument list and return an int; thus, those methods have a return value of type int. You can call these methods in any expression in your program where you could use an int.

The value of the first method, getMonth( ), is the value of the month in the object. Similarly, the value of getDay( ) is the value of the day in the object, and the value of getYear( ) is the value of the year. These “get” methods are formally called accessor methods; they enable clients to access the value of the instance variables of an object.

The next three methods in the EndOfTimes class API take one argument of type int and do not return a value, which is indicated by the keyword void. These methods are called in standalone statements. The first method, setMonth( int mm ), changes the value of the month in the object to the value of the method’s argument, mm. Similarly, setDay( int dd ) changes the value of the day in the object, and setYear( int yy ) changes the value of the year in the object to the value of the method’s argument. These “set” methods are formally called mutator methods; they enable a client to change the value of the instance variables of an object.

The code below illustrates how to use some of the methods of the EndOfTimes class.

Screen Shot 2018-12-20 at 1.41.35 PM

EndOfTimes is underlined red because this API class doesn’t exist and is therefore merely hypothetical. The year of Kali Yuga is too far so it is also not useful to place an end to time so far away.

Line 10 calls the getMonth method for the maitreya object. When line 10 is executed, control transfers to the getMonth method. When the getMonth method finishes executing, the value it returns (7) replaces the method call in the statement. The statement then effectively becomes:

Screen Shot 2018-12-20 at 1.15.04 PM.png

In lines 16–17, we print the value of the day in the kaliYuga object. Again, control transfers to the getDay method, then its return value (30) replaces the method call. So the statement effectively becomes:

Screen Shot 2018-12-20 at 2.00.29 PM

Line 16 calls the setDay method, which is used to change the value of the day for an object. The setDay method takes one int argument and has a void return value. Line 17 is a complete statement, because the method call to a method with a void return value is a complete statement. The method changes the value of the day in the kaliYuga object. Then, on line 19, we instantiate another object, christ, with a month, day, and year of 11, 12, 1817, which I demonstrate by printing the values returned by calls to the getMonth, getDay, and getYear methods. Baha u’llah was born on that day month and year, and claimed to be the return of Jesus. (This is not, however, the beginning of the new calendar for the Baha’i.)

On line 25, we call the nextDay method, which has a void return value, and increments the date to the next day, and then we print the new values of the christ object.

 

Class Basics and Benefits

Screen Shot 2018-12-19 at 1.57.19 PM

In Java, classes are composed of data and operations on the data.

Ultimately, there only exist data and operations, but some data and operations can become a guiding template for objects. Objects are data and operations that follow the guide. Think of the class as a generic description, and an object as a specific item of that class.

For example, a Griffith class might have the following data: name, age, and allegiance. All Griffiths have these three data items, and that’s what makes it a Griffith class. We can create an object of the Griffith class by specifying an identifier for the object (for example, griffith1) along with a name, age, and allegiance for a particular Griffith (for example, Femto, 24 , God Hand). The identifier of the object is called the object reference.

Creating an object of a class is called instantiating an object, and the object is called an instance of the class. Many objects can be instantiated from one class. There can be many instances of the Griffith class, that is, many Griffith objects can be instantiated from the Griffith class. For example, we could create a second object of the Griffith class, griffith2, with its data as White Falcon, 24, Band of the Falcon.

The data associated with an object of a class are called instance variables, or fields, and can be variables and constants of any primitive data type (byte, short, int, long, float, double, char, and boolean), or they can be objects of a class.

The operations for a class, called methods, set the values of the data, retrieve the current values of the data, and perform other class-related functions on the data. For example, the Griffith class would provide methods to set the values of the name, age, and allegiance; retrieve the current values of the name, age, and allegiance; and perhaps promote a Griffith to another age.

Invoking a method on an object is called calling the method. With a few exceptions, only class methods can directly access or change the instance variables of an object. Other objects must call the methods to set or retrieve the values of the instance variables. Together, the fields and methods of a class are called its members.

In essence, a class is a new data type, which is created by combining items of Java primitive data types and objects of classes. Just as the primitive data types can be manipulated using arithmetic operators (+, −, *, /, and %), objects can be manipulated by calling class methods.

We like to think of classes as similar to dragons: a protective outer armor to encase pulpy organs. Because the methods to operate on the data are included in the class, they provide a protective coating around the data inside. In a well-designed class, only the class methods can change the data. Methods of other classes cannot directly access the data. We say that the data are private to the class.

People higher in autism or psychopathy are well-designed classes in this sense. Entheogens allow class methods from elsewhere to change the data. – Speaking of which, psilocybin might be legalized in Oregon. Keep an eye on that because I’m willing to take that market share.

Sorry, I get distracted, what I was saying was that the class encapsulates the data, and the methods provide the only interface for setting or changing the data values. The benefit from this encapsulation is that the class methods ensure that only valid values are assigned to an object. For example, a method to set Griffith’s allegiance may not accept the value Argonauts.

Let’s look at another example of a class. The Arachnophobia class, has the instance variables signs, reasons, and treatment. An object of this class, arachnophobia1, could be instantiated with data values of uneasy, instinctive, and systematic desensitization. Another object of the Arachnophobia class, arachnophobia2, might be instantiated with the values panic attack, cultural, relaxation techniques. Methods of the Arachnophobia class ensure that only valid values are set for the signs, reasons, and treatment.

For example, the class methods may not allow us to set a date with a value of “contentment”, “magic”, and “prayer”. If we were dealing with dates, other class methods may increment the date to the next day and provide the date in mm/dd/yyyy format.

Notice that the class names we used, Griffith and Arachnophobia, begin with a capital letter, and the object names, griffith1, griffith2, and arachnophobia1, start with a lowercase letter.

By convention, class names start with a capital letter. Object names, instance variables, and method names conventionally start with a lowercase letter. Internal words start with a capital letter in class names, object names, variables, and methods. There are many benefits to using classes in a program. Some of the most important benefits include reusability (not only in the current program but also in other programs), encapsulation, and reliability. A well-written class can be reused in many programs. For example, an Arachnophobia class in the brain could be used in a film program, a survival program, a science program, and many more applications that rely on arachnophobias.

Reusing code is much faster than writing and testing new code. As an added bonus, reusing a tested and debugged class in another program makes the program more reliable. Encapsulation of a class’s data and methods helps to isolate operations on the data. This makes it easier to track the source of a bug. For example, when a bug is discovered in an object of the Griffith class, then you know to look for the problem in the methods of the Griffith class, because no other code in your program can directly change the data in a Griffith object.

This is why Mind partitioned itself into Name classes. It makes it easier to directly control   where we are going.

You do not need to know the implementation details of a class in order to use it in your program. Does a Date class store the date in memory as three integers, month, day, and year? Or is the date stored as the number of milliseconds since 1980? As with the unknowable binding mechanism causing us, the beauty of object orientation is that we don’t need to know the implementation of the class; all we need to know is the class application programming interface (API), that is, how to instantiate objects and how to call the class methods.

Object-Oriented Programming Introduction

Writing computer programs that use classes and objects is called object-oriented programming, or OOP. Every Java program consists of at least one class.

In the following posts, I’ll introduce you to object-oriented programming as a way to use classes that have already been written. Classes provide services to the program. These services might include writing a message to the program’s user, popping up a dialog box, performing some mathematical calculations, formatting numbers, drawing shapes in a window, or many other basic tasks that add a more professional look to even simple programs. The program that uses a class is called the client of the class.

One benefit of using a prewritten class is that we don’t need to write the code ourselves; it has already been written and tested for us. This means that we can write our programs more quickly. In other words, we shorten the development time of the program. Using prewritten and pretested classes provides other benefits as well, including more reliable programs with fewer errors.

This is similar to when we use latent space in machine learning for faster progress. Training in latent space is like using a prewritten class; taken to the limit, the algorithm you are is the “fastest” possible progress since the processing involves no time sweeping forward at all.

In the following post, we’ll explore how using prewritten classes can add functionality to our programs.

Shortcut Operators

A common operation in programming is adding 1 to a number (incrementing) or subtracting 1 from a number (decrementing). For example, if you were counting how many data items the user entered, every time you read another data item, you would add 1 to a count variable. Because incrementing or decrementing a value is so common in programming, Java provides shortcut operators to do this: ++ and −−. (Note that there are no spaces between the two plus and minus signs.) The statement

Screen Shot 2018-12-18 at 6.32.15 AM

adds 1 to the value of count, and the statement

Screen Shot 2018-12-18 at 6.34.07 AM

subtracts 1 from the value of count. Thus,

Screen Shot 2018-12-18 at 6.32.15 AM

is equivalent to

Screen Shot 2018-12-18 at 6.41.41 AM.png

and

Screen Shot 2018-12-18 at 6.34.07 AM

is equivalent to

Screen Shot 2018-12-18 at 6.44.23 AM.png

Both of these operators have prefix and postfix versions. The prefix versions precede the variable name (++a or −−a) whereas the postfix versions follow the variable name (a++ or a−−). Both increment or decrement the variable. If they are used as a single, atomic statement (as in the preceding statements), there is no difference between the two versions. So

Screen Shot 2018-12-18 at 5.21.36 PM.png

is functionally equivalent to

Screen Shot 2018-12-18 at 5.23.44 PM.png

and

Screen Shot 2018-12-18 at 5.31.30 PM

is functionally equivalent to

Screen Shot 2018-12-18 at 5.33.27 PM

However, if they are used inside a more complex expression, then they differ as follows: The prefix versions increment or decrement the variable first, then the new value of the variable is used in evaluating the expression. The postfix versions increment or decrement the variable after the old value of the variable is used in the expression.

The example below illustrates the difference:

Screen Shot 2018-12-18 at 5.44.24 PM

Lines 9 and 10 declare and initialize two int variables, a and b, to 6 and 2, respectively. In order to illustrate the effect of both the prefix and postfix increment operators, we output their original values at lines 12 and 16. At line 13, we use the prefix increment operator to increment a inside an output statement; a is incremented before the output statement is executed, resulting in the output statement using the value 7 for a. At line 17, we use the postfix increment operator to increment b inside an output statement; b is incremented after the output statement is executed, resulting in the output statement using the value 2 for b. Lines 14 and 18 simply output the values of a and b after the prefix and postfix operators were used at lines 13 and 17. Below is the output of this example:

Screen Shot 2018-12-18 at 5.51.46 PMAnother set of shortcut operators simplify common calculations that change a single value. For example, the statement

Screen Shot 2018-12-18 at 5.53.22 PM

can be simplified as

Screen Shot 2018-12-18 at 5.53.29 PM.png

The value added to the target variable can be a variable name or a larger expression. The shortcut addition operator (+=) is a single operator; there are no spaces between the + and the =. Also, be careful not to reverse the order of the operators. For example, in the following statement, the operators are reversed, so the compiler interprets the statement as “assign a positive 2 to a.”

Screen Shot 2018-12-18 at 5.57.19 PM

Java provides shortcut operators for each of the basic arithmetic operations: addition, subtraction, multiplication, division, and modulus. These operators are especially useful in performing repetitive calculations and in converting values from one scale to another. For example, to convert feet to inches, we multiply the number of feet by 12. So we can use the *= shortcut operator:

Screen Shot 2018-12-18 at 5.59.04 PM.png

Converting from one scale to another is a common operation in programming. For example, in an earlier post we invented a concept and partitioned it into its constituent at different levels of granularity. You might also need to convert hours to seconds, feet to square feet, or Fahrenheit temperatures to Celsius.

Below are demonstrated each of the shortcut arithmetic operators and the output.

Screen Shot 2018-12-18 at 6.36.59 PM

These are the shortcut operators:

Screen Shot 2018-12-18 at 6.38.10 PM

As with lobsters, humans, angels, and superintelligences, operators have a hierarchy/ order of precedence:

Screen Shot 2018-12-18 at 6.39.12 PM

Those at the top are always first.

screen shot 2019-01-25 at 12.56.59 pm

Mixed-Type Arithmetic and Type Casting

So far, we’ve used a single data type in the expressions we’ve evaluated. But life isn’t always like that. Calculations often involve data of different primitive types.

When calculations of mixed types are performed, lower-precision operands are converted, or promoted, to the type of the operand that has the higher precision.

This also occurs with human minds broadly. We can notice that there is a tendency towards survival/ greater alignment with Born Rule’s probability density, but we cannot use simple rules that chunk minds into the big 5 psychometric traits for instance, and deduce which should be converted to which on the ascent.

In Java, however, the promotions of data types is quite easy to understand:

The promotions are performed using the first of these rules that fits the situation:

1.   If either operand is a double, the other operand is converted to a double.

2.   If either operand is a float, the other operand is converted to a float.

3.   If either operand is a long, the other operand is converted to a long.

4.   If either operand is an int, the other operand is promoted to an int.

5.   If neither operand is a double, float, long, or an int, both operands are promoted to int.

The table below summarizes these rules of promotion.

Screen Shot 2018-12-13 at 8.33.29 PM

This arithmetic promotion of operands is called implicit type casting because the compiler performs the promotions automatically, without our specifying that the conversions should be made. Note that the data type of any promoted variable is not permanently changed; its type remains the same after the calculation has been performed.

The table above shows many rules, but essentially, any arithmetic expression involving integers and floating-point numbers will evaluate to a floating-point number. Lines 9 to 12 of the code below illustrates the rules of promotion. At line 11, the expression PI * radius * radius is a mixed-type expression. This expression will be evaluated left to right, evaluating the mixed-type expression PI * radius first. PI is a double and radius is an int. Therefore, radius is promoted to a double (4.0) and the result of PI * radius is a double (12.56636). Then, the next calculation (12.56636 * radius) also involves a mixed-type expression, so radius is again promoted to a double (4.0). The final result, 50.26544, is a double and is assigned to area. The figure below shows the output of the complete program.

Sometimes, it’s useful to instruct the compiler specifically to convert the type of a variable. In this case, you use explicit type casting, which uses this syntax:

(dataType) (expression)

The expression will be converted, or type cast, to the data type specified. The parentheses around expression are needed only when the expression consists of a calculation that you want to be performed before the type casting.

Type casting is useful in calculating an average. The example shows how to calculate your average test grade. Your test scores are 94, 86, 88, and 97, making the combined total score 365. We expect the average to be 91.25.

Screen Shot 2018-12-17 at 9.29.38 PM.png

Line 16 first attempts to calculate the average but results in a wrong answer because both total and count are integers. So integer division is performed, which truncates any remainder. Thus, the result of total / count is 91. Then 91 is assigned to average, which is a double, so 91 becomes 91.0. Line 22 is a second attempt to calculate the average; again, this code does not work correctly because the parentheses force the division to be performed before the type casting. Thus, because total and count are both integers, integer division is performed again. The quotient, 91, is then cast to a double, 91.0, and that double value is assigned to average.

At line 28, we correct this problem by casting only one of the operands to a double. This forces the other operand to be promoted to a double. Then floating-point division is performed, which retains the remainder. It doesn’t matter whether we cast total or count to a double. Casting either to a double forces the division to be a floating-point division.

This is the output:

Screen Shot 2018-12-18 at 6.17.23 AM

 

 

Division by Zero

As you might expect, Java does not allow integer division by 0. If you include this statement in your program,

Screen Shot 2018-12-13 at 7.00.51 PM

the code will compile without errors, but at run time, when this statement is executed, the JVM will generate an exception and print an error message on the Java console:

Screen Shot 2018-12-13 at 7.14.57 PM

In most cases, this stops the program. When you learn selection techniques, you will be able to avoid dividing by zero by first testing whether the divisor is zero before performing the division. In contrast, floating-point division by zero does not generate an exception. If the dividend is nonzero, the answer is Infinity. If both the dividend and divisor are zero, the answer is NaN, which stands for “Not a Number.” The example below illustrates the three cases of dividing by zero.

Screen Shot 2018-12-13 at 8.19.55 PM

As we can see on the output shown, line 16 never executes. The exception is generated at line 15 and the program halts execution.

Screen Shot 2018-12-13 at 8.21.16 PM

Although floating-point division by zero doesn’t bring your program to a halt, it doesn’t provide useful results either. It’s a good practice to avoid dividing by zero in the first place… stupid Simulators causing black holes all over the place.