Java Object Tostring
# Java Object toString() Method
[Java Object Class](#)
* * *
The Object toString() method is used to return the string representation of an object.
### Syntax
object.toString()
### Parameters
* **None**.
### Return Value
Returns the string representation of the object.
Default return format: Object's class name + @ + hashCode's hexadecimal string.
### Example
The following example demonstrates the use of the toString() method:
## Example
class TutorialTest{public static void main(String[]args){// toString() with Object Object obj1 = new Object(); System.out.println(obj1.toString()); Object obj2 = new Object(); System.out.println(obj2.toString()); Object obj3 = new Object(); System.out.println(obj3.toString()); }}
The output of the above program is:
java.lang.Object@d716361 java.lang.Object@6ff3c5b5 java.lang.Object@3764951d Output format explanation:
* **java.lang.Object** - Class name
* **@** - Symbol
* **d716361** - Hexadecimal value of the hash code
Array class calling toString() method:
## Example
class TutorialTest{public static void main(String[]args){// toString() with array// Create an array String[]array = {"Google", "", "Taobao"}; System.out.println(array.toString()); // Array element values return a string representation// Array inherits from the Object class, so toString() method can be used directly System.out.println(array.toString()); // }}
The output of the above program is:
* * Java Object Class](#)
YouTip