Objects and referencs

All manipulation of objects is done through references to objects. It is common to see some confusion between references and the objects they refer to. References are an indirect reference to the actual grouping of code and data which is the object. Bruce Eckel makes a beautiful analogy in "Thinking in Java" when he says.

“You might imagine this scene as a television (the object) with your remote control (the reference). As long as you’re holding this reference, you have a connection to the television, but when someone says “change the channel” or “lower the volume,” what you’re manipulating is the reference, which in turn modifies the object. If you want to move around the room and still control the television, you take the remote/reference with you, not the television.”

The implication of this is that you never directly manipulate an object reference. Thus you can never use a math operator such as *, - or + on an object reference.

Last modified: Sunday, 20 September 2015, 07:21 PM