December 1999
Intermediate to advanced
816 pages
20h 27m
English
Classes define what an object will be like, its state and behavior. If I create a primitive and initialize it as in
int x = 6;
there is a memory location set aside that contains the number 6 as an int. x refers directly to that memory location. If, however, I code
JFrame mainFrame = new Frame();
mainFrame is not the name of the JFrame object, but an object reference to the JFrame object. This has important ramifications. Consider this little class definition:
public class Book
{
boolean reservedStatus;
int checkOutPeriod;
String title;
}
When another class does
Book b = new Book();
memory is allocated for the data members reservedStatus and checkOutPeriod. Furthermore, that memory is given default, initial values, such as false ...
Read now
Unlock full access