Object References: A Review
An object exists only after it has been constructed.
Once it exists,
an object is "reached" by going through a reference.
Often, the reference is held in a reference variable such as str, above.
For example,
the following first declares a reference variable,
then constructs an object and puts a reference to it in str:
String str; // declare a reference variable
str = "Hello World" ; // construct the object and
// save its reference
Of course, it is OK to declare an object
reference variable and not place a reference in it
(it might only sometimes be needed.)
And it is OK to use the same reference variable for
different objects at different times:
String str;
str = "Hello World" ;
. . . .
str = "Good-by" ;
|