Java Data Type Tutorial - Java String.toString()








Syntax

String.toString() has the following syntax.

public String toString()

Example

In the following code shows how to use String.toString() method.


public class Main {

  public static void main(String[] args) {
    String s = "java2s.com";
    System.out.println(s.toString());
  }
}

The code above generates the following result.