CIS525 - Lecture#10 - October 9, 2000
CIS 525 10/9/00
Chap 7, cont:
See page 253 of Hall for 'Test2.java'
See page 253 of Hall for 'Test3.java' for example of static initialization
Static Initialization block:
public class SomeClass {
int[] values = new int[12];
static {
for(int i = 0; i < values.length; i++)
values[i] = 2 * i + 5;
}
}
In Java, there are no destructors, uses 'garbage collection' instead,
(reference counter: memory is re-allocated if the counter for a pointer, etc. reaches 0)
Overloading in Java is similar to C++
See page 261 in Hall for 'Test4.java' for example of full class definition
'Ship.java' on page 265 of Hall uses public accessor functions to
access/manipulate private class attributes
This is far more desirable, of course, than declaring all variables public
If you are using 'javac' for compiling, you may need to use the following command:
javac -depend Ship.java
this checks 3rd order file dependencies. If a class definition resides in the
same directory, there is no problem. If not, however, the compiler needs to know
to look for it
Documentation in Java:
/**
DOCUMENTATION
*/
utility called 'javadoc' will "see" these entries and create an index similar to a
data dictionary, showing definitions and declarations
example:
javadoc Ship.java
this generates documents and index in a html file
in order to see the images for this index, you must replace each instance of the following: