This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is inside a reference variable." Watch "What is inside a reference variable." New topic

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

Joined: Jul 08, 2003
Posts: 24189

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: What is inside a reference variable.
It's not a secret anymore!