3.2 Creating Objects Using Constructors
A class describes a generic template for creating, or instantiating, objects. In fact, an object must be instantiated before it can be used. To understand how to instantiate an object of a class and how to call methods of the class, we must know the API of a class, which the creators of the class make public. Table 3.1 shows the API of the SimpleDate class, written by the authors of this text.
TABLE 3.1 The SimpleDate Class API
SimpleDate Class Constructor Summary |
|
---|---|
SimpleDate( ) creates a SimpleDate object with initial default values of 1, 1, 2000. SimpleDate( int mm, int dd, int yy ) creates a SimpleDate object with the initial values of mm, dd, and yy. |
|
SimpleDate Class Method Summary ... |
Get Java Illuminated, 5th Edition 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.