Java Reference
In-Depth Information
An object reference describes the location of an object.
Rectangle box = new Rectangle(5, 10, 20, 30);
Figure 16
An Object Variable Containing an Object Reference
53
54
Figure 17
Two Object Variables Referring to the Same Object
Figure 18
A Number Variable Stores a Number
the variable box refers to the
Rectangle
object that the
new
operator constructed.
Technically speaking, the
new
operator returned a reference to the new object, and
that reference is stored in the
box
variable.