This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is inside a reference variable.

 
Ashok Pradhan
Ranch Hand
Posts: 180
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic