Java Data Type Tutorial - Java String(StringBuilder builder) Constructor








Syntax

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

public String(StringBuilder builder)

Example

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

//from  w ww.java 2s . co  m


public class Main {
  public static void main(String[] argv) {
    StringBuilder sb = new StringBuilder();
    sb.append("java2s.com");
   
    System.out.println(new String(sb));
    
  }
}

The code above generates the following result.