Javatpoint Logo
Javatpoint Logo

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

Test it Now

Output:

Example 2

Test it Now

Output:

Addition of 10 and 20 : 
Answer : 30
[email protected]

Next TopicJava Object Class





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA