Classes
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 ...
Get PURE Java™ 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.