Facebook Page Twitter Page LinkedIn Page
× Java Tutorial Java Advanced Java Resources

The Java string toString() method is used to return the object (which is already a string!) itself.


public String toString()


No parameter is required.

Return Value

Returns the string itself.


In the below example, toString() method to used to return the string object itself.

public class MyClass {
  public static void main(String[] args) {
    String MyString = "Hello World";
    String NewString = MyString.toString();


The output of the above code will be:

Hello World

❮ Java String Methods