*
The moose likes Beginning Java and the fly likes What is inside a reference variable. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is inside a reference variable." Watch "What is inside a reference variable." New topic
Author

What is inside a reference variable.

Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 180

int i=10;
//i stores bit patern of 10(1010)
Dog d = new Dog();
But what d stores ?Is that mean d stores the memory location of (new Dog).As like pointers.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Java will not let you see that bit pattern, no matter how hard you try; there's no way to convert a reference into an int, as you can in C++. So it truly doesn't matter.

But yes, it's a pointer, or perhaps a pointer to a pointer (a "handle"), which allows for object movement and heap compaction.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is inside a reference variable.
 
Similar Threads
Iterator in lists
problem to understand d1.d=d2
Serialization
please tell me what is wrong in my code
Object behaviour.