Incremental Java
Review of Objects
-
Review
-
We've only touched on some aspects of what an object is.
You don't know a lot about objects right now, but what you do
know is important.
- Object variables are boxes.
- Unlike primitive variables where boxes hold a value of
a type, object variables store handles.
- An object variable can either hold a single handle, or
it holds nothing (null).
- If it holds a handle, it's a handle to a balloon, which
is the object itself.
- Object variables do not contain objects. They contain handles.
The handles are attached to objects.
- Objects need to be constructed.
- When an object is constructed, it makes the object, and a handle
to the object. This handle is stored by the object variable.
- If you do an assignment such as x = y where x
and y are both object variables, then the assignment
copies the handle of y to x. Now, both object
variables have a handle to the same object.
- So far, the only type that is an object is String