115
Java Object toString() Method
toString() is the method of Object class. This method returns a string that is the representation of the object, which contain name of the class of which the object is an instance. The returned string is in the following form:-
getClass().getName() + ‘@’ + Integer.toHexString(hashCode())
Syntax
Returns
It return a string representation of the object.
Example 1
Output:
Example 2
Output:
Addition of 10 and 20 : Answer : 30 [email protected]
Next TopicJava Object Class