Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is this the address of the object

 
faisal usmani
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,

Suppose i have a class and in the class in i am not overriding toString() of Object class.

Here is the code.

class Foo
{
int y ;
}

class Demo
{
public static void main(String arg[])
{
def f = new def();

System.out.println(f);

}
}


On running this code i get o/p as
def@1bd03e might be different on your jvm. But what actually is this def@1bd03e , is it the address where object is on the heap.


Thanx in advance
[ April 22, 2006: Message edited by: faisal usmani ]
 
edirg559
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is the memory spot where the "def" object is residing in the heap. def@1bd03e describes the def object name you created followed by @ and its hash code.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Erik Dirgaria:
Yes, it is the memory spot where the "def" object is residing in the heap. def@1bd03e describes the def object name you created followed by @ and its hash code.


No. It may be related to that address; but there is certainly no guarantee that it is the address. As Erik says, that number is the return value of the hashCode() method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic