Java StringBuilder(String str) Constructor

Syntax

StringBuilder(String str) constructor from StringBuilder has the following syntax.

public StringBuilder(String str)

Example

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


/*from ww w. ja va2  s  .c  o m*/
public class Main {

  public static void main(String[] arg) {

    String phrase = "abced";
    StringBuilder buffer = new StringBuilder(phrase);

    System.out.println(buffer);
  }

}

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