File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Mock Exam Errata and the fly likes toString Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "toString" Watch "toString" New topic


premji danicha

Joined: Oct 15, 2001
Posts: 1
If return type of toString is String but it also return a hashcode and hashcode method return type is int. when i print the reference of any user define class object. if user define class has not toString overide method .
for example:
Myclass c=new Myclass();
System.out.println( c ); // output Myclass@hashcodenumbers
Any can inform me that how it is happend.
Nain Hwu
Ranch Hand

Joined: Sep 16, 2001
Posts: 139
Take a look at the toString() method for Object class.
It says:

this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashcode())
I agree. Here's the link:
subject: toString
It's not a secret anymore!