aspose 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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 24166
    
  30

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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is this the address of the object
 
Similar Threads
Has-A doubt
Unfamiliar Scala syntax
Scala exercises for beginners (in FP)
Scala mixin behavior
Project Euler problems with Scala