>> Saturday, October 20, 2012
The toString() method is useful for debugging. By default, when an object is printed out in a print stream like System.out, the toString() method of the object is automatically called.
While develping the code the developers used to check the object properties are getting through the object or not. For this print statement will be useful to quick test in the console.
public String toString() Returns: a string representation of the object.Let us take a Person class and try to print the person object using the System.out.println() statement.