Java Data Type Tutorial - 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 w  w w  .ja va 2s . 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.