This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Diff b/w ref variable & object ref  RSS feed

 
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
Sheriff
Posts: 24217
38
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
Boost this thread!