Java Object toString() MethodtoString() 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()) SyntaxReturnsIt return a string representation of the object. Example 1Test it NowOutput: JavaObjecttoStringExample1@7852e922 Example 2Test it NowOutput: Addition of 10 and 20 : Answer : 30 JavaObjecttoStringExample1@7852e922
Next TopicJava Object Class
|