str = new String( "The Gingham Dog" );
The new
operator creates an object using the constructor String().
Review: Two steps take place when an assignment operator is executed:
=
is evaluated.=
.When an object is constructed, these steps happen like this:
String str; // name for a future object
str = new String( "The Gingham Dog" );
--+-- ----------------+--------------
| |
|
| 1. An object is created using the constructor.
| The Java system keeps track of
| how to find the object.
2. A reference to the object is stored in the variable str
.
There are two types of things in the above: the object, and a reference to the object.
Are your name and the actual you different things?
Are an object reference and the actual object different things?