Java toString() method.



The toString() method of the String class returns itself to a string.

Example

Live Demo

import java.io.*;
public class Test {
   public static void main(String args[]) {
      String Str = new String("Welcome to Tutorialspoint.com");
      System.out.print("Return Value :");
      System.out.println(Str.toString());
   }
}

Output

Return Value :Welcome to Tutorialspoint.com

Advertisements