Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Which toString() method does System.out.println() call?

843789Aug 5 2010 — edited Aug 17 2010
Which toString() method does System.out.println() call? I know that if I did something like System.out.println( new myClass() ) that the toString being called would be that of the myClass class.

My initial thought about this was that System.out.println() is the equivalent of System.out.println( new Object() ) but I remember trying that in a test program and it gave me a myClass@some_hash_code type of message when adding the new Object() part within the System.out.println().

Could someone please tell me which toString the System.out.println() statement calls? Also, it would be great if an elaboration follows :).

Any input woudl be greatly appreciated!
Thanks in advance!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 14 2010
Added on Aug 5 2010
31 comments
849 views