June 2018
Beginner
722 pages
18h 47m
English
The toString() method of the java.lang.Object class looks like this:
public String toString(){ //return string representation of the object}
This method is typically used to print the content of the object. Its default implementation looks like this:
public String toString() { return getClass().getName()+"@"+Integer.toHexString(hashCode());}
As you can see, it is not very informative, so programmers re-implement it in their classes. This is the most commonly re-implemented method of the class Object. Programmers practically do it for each of their classes. We will explain more about the String class and its methods in Chapter 9, Operators, Expressions, and Statements.
Read now
Unlock full access