aspose file tools*
The moose likes Beginning Java and the fly likes Diff between object and object reference? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Diff between object and object reference?" Watch "Diff between object and object reference?" New topic
Author

Diff between object and object reference?

Sneha Neil
Greenhorn

Joined: May 31, 2004
Posts: 5
Hi,

Can you please explain if there is any difference between object and object reference? I had this doubt while reading about static modifiers.

Thanks,
Sneha
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
When we create an object with "new Thing()" the JVM finds the class description of Thing, allocates some memory for its variables and initializes any variables that need it. (The JVM does much more we can ignore right now.) So I guess you could say the "object instance" is that chunk of initialized memory. As you do things to the object you modify that chunk of memory.

An object reference is a very small thing that just points to the object instance in memory. You could have lots of references pointing to the same object. Let's make three to demonstrate:

Thing a = new Thing();
Thing b = a;
Thing c = b;

I'd warn you not to parse these terms too literally when reading books and documentation. It's a very persnickity level of precision to make these words mean the same thing every time you see them. People are often a bit fast & loose with the distinction in casual writing.

Hope that helps!


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
kelvin cheung
Ranch Hand

Joined: Mar 27, 2004
Posts: 120
i think its like you and me.

we are humans, but we got names
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Diff between object and object reference?