How do you declare an integer?
If you want this variable to have a value, you would
initialize it like so:
Now, an object reference is just like any other variable. So, if the class is named Date, and you want your variable name to be curDate, you say:
That takes care of the declaration. The construction is like initializing the integer variable, but the syntax is a little different:
- Date curDate = new Date();
This also has a different name - it is called
instantiation, and we call curDate an
instance of the Date class.