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 Is this the address of the object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Is this the address of the object " Watch "Is this the address of the object " New topic
Author

Is this the address of the object

faisal usmani
Ranch Hand

Joined: Jan 14, 2006
Posts: 139
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

Joined: Apr 19, 2006
Posts: 19
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

Joined: Jul 08, 2003
Posts: 24183
    
  34

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.


[Jess in Action][AskingGoodQuestions]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Is this the address of the object