Method calls and member references

Members is another way the Java books refer to variables and methods in classes. You must uniquely identify a member of a class or object to call it or access it. Classes contain variables and methods, but classes can themselves be logically grouped into packages, so it may be necessary to specify the package, class, and member name to access something. This is done as follows:

package.class.variable   or   package.class.method()

In Java the parens are needed if calling a method, even if no parameters are passed. NetRexx does not require the parens if no parms are passed, unless calling a contructor to create a new object. To further complicate things, package names can have multiple levels (such as java.lang) also separated by periods, leading to references like this:

java.lang.String.substring()

If variable OBJ contains the handle of an object with a method named "query", you would call the query method as follows:

OBJ.query();

This syntax does not make it obvious where something really lives when you access it! Thus looking at our first example "Hello World" program we see:

System.out.println("Hello");

It is not obvious that "System" is a class containing a variable "out" which points to an object with a method named "println", rather than a class named "out"  with a method named "println" in a package named "System". There seems to be a recommended convention of beginning class names with a capital letter, which helps somewhat.