File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

toString

 
premji danicha
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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())
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic