wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Diff b/w ref variable & object ref Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Diff b/w ref variable & object ref" Watch "Diff b/w ref variable & object ref" New topic

Diff b/w ref variable & object ref

khateeb syed

Joined: Jun 25, 2005
Posts: 9

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)

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

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

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183

"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.

[Jess in Action][AskingGoodQuestions]
Consider Paul's rocket mass heater.
subject: Diff b/w ref variable & object ref
Similar Threads
Arrays doubt
Confusion with this Output
Garbage Collection
Array of Objects
variable or reference?