Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Diff b/w ref variable & object ref

 
khateeb syed
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I would like to know the difference between Object reference & Reference variable.

What i understand is that an Object reference is a variable storing the address of the object in the memory like
Dimension d = new Dimension();//here d is an object ref( can this also be called as ref variable)

Now,
Dimension d; // now can we call the d as reference variable of type Dimension

plz let me know if i'm goin wrong anywhere.

Thanks.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"d" in your examples is always a reference variable. In your first case, it's a reference variable containing an object reference. In your second case, it's a reference variable that's not holding an object reference yet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic