You will no doubt notice some strange notation in the
Test Files. The method calls and field acccesses
are annotated so that you don't have to look in any other source or class
files to determine types.
Java overloads the period symbol in references to methods, statics, and fields. Given
w.x.y.z
we can't tell whether this is some static field z in a class w.x.y,
or perhaps y is a static field in class w.x and z is a field
of the instance Y
To simplify matters, the notation for fields and methods is as follows:
- The period symbol is used only within a class reference. Thus,
w.x.y.z is class z in package w.x.y.
- To reference a static field or method of a class, use two colons (::), so that
java.lang.System::out is the System.out output stream.
- To reference a field of an instance, use ->. Thus,
(obj)->a references field a using the reference obj
- Methods work the same way. To call a static method, use:
java.lang.Math::abs(num).
- All references and methods also include the return type of the result, which appears
after a single colon. Thus,
the reference above for System.out is really
java.lang.System::out : java.io.PrintStream
and to print something using println
(java.lang.System::out : java.io.PrintStream) -> println : void ("hello")
and the absolute value method would be
java.lang.Math :: abs : int (num)