Java Data Type Tutorial - Java String(String original) Constructor








Syntax

String(String original) constructor from String has the following syntax.

public String(String original)

Example

In the following code shows how to use String.String(String original) constructor.

public class Main {
  public static void main(String args[]) {
    
    String s = new String("java 2s.com");
    String s2 = new String(s);
    
    System.out.println(s2);
  }
}

The code above generates the following result.