File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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.