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[]) {
    /*w ww.j av  a  2s .c  o  m*/
    String s = new String("java 2s.com");
    String s2 = new String(s);
    
    System.out.println(s2);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable