This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Diff between object and object reference?

 
Sneha Neil
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
kelvin cheung
Ranch Hand
Posts: 120
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic