Java Q&A: The ultimate superclass, Part 3

See the original posting on JavaWorld

My previous post in this three-part series on the java.lang.Object class and its methods covered finalize(), getClass(), and hashCode(). In this post, you explore toString(), the wait/notification methods, and Object‘s methods in an interface and Java 8 context.

String Representation

Q: What does the toString() method accomplish?

A: The toString() method returns a string representation of the object on which this method is called. The returned string is useful for debugging purposes.

Q: What does the string representation look like when toString() isn’t overridden?

To read this article in full or to leave a comment, please click here