Invoking a method


Werbung

An object's method is called by using a statement of the following form:

notThatSimpleObject.getValue();

 

To specify, which object's method you want to call, the name of that object must be written. After the object's name, the name of the method follows. To call the same method, but now for similarObject, you would have to write:

similarObject.getValue();

 

(Do you remember the term reusability, mentioned in the "Object Orientation" section?)

 

Our example class offers no way to change our objects' states, but we may get some information about the states. The getValue() method returns an integer value, which represents an object's current state.

Thus, if you want to get the state of similarObject, you might write something like:

int currentState;

currentState = similarObject.getValue();

 

Of course, the variable that receives the return value must be of the same type as the returned value.

 

 

After this short description of some Java basics, let's go on to the serious stuff. The next section shows you, how to work with the neural network classes.

Neural Net Components in an Object Oriented Class Structure