"Object" vs "Object Variable" in Java?

I'll bite.

The Object is the instance itself, whereas the Object Variable is the reference to the Object.

Here's a contrived example:

Object o = new Object();
Object ref1 = o;

In his case, there is a single instance of the Object, but it is referenced by two Object Variables: o and ref1.

When an Object is no longer referenced by an Object Variable, the Object is garbage collected.


It's a synonym of "instance variable":

class A {
    static int m;  // <-- class variable
    int n;         // <-- instance variable
    ...
}

Evidently, this term is not so commonly used, and it would better to avoid any potential ambiguities by just sticking with "instance variable".

Tags:

Java

Object