Example usage for java.lang StringBuilder StringBuilder

List of usage examples for java.lang StringBuilder StringBuilder

Introduction

In this page you can find the example usage for java.lang StringBuilder StringBuilder.

Prototype

@HotSpotIntrinsicCandidate
public StringBuilder() 

Source Link

Document

Constructs a string builder with no characters in it and an initial capacity of 16 characters.

Usage

From source file:Main.java

public static void main(String[] argv) {
    StringBuilder sb = new StringBuilder();
    sb.append('a');
    System.out.println(sb.toString());
}

From source file:Main.java

public static void main(String[] argv) {
    StringBuilder sb = new StringBuilder();
    sb.append(1.2);//from w  ww  . j ava 2s. com
    System.out.println(sb.toString());
}

From source file:Main.java

public static void main(String[] args) {
    StringBuilder sb = new StringBuilder();
    System.out.println(sb.capacity());
}

From source file:Main.java

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

From source file:Main.java

public static void main(String[] argv) {
    StringBuilder sb = new StringBuilder();
    sb.append(true);/*w ww  . jav a  2s. c  om*/
    System.out.println(sb.toString());
}

From source file:Main.java

public static void main(String[] argv) {
    StringBuilder sb = new StringBuilder();
    sb.append("java2s.com");
    String sub = sb.substring(1, 2);
    System.out.println(sub);/*from  w w w  .  j av a 2 s. c  om*/
}

From source file:Main.java

public static void main(String args[]) {
    StringBuilder sb = new StringBuilder();
    sb.append("java2s.com");
    int index = sb.indexOf("a");
    System.out.println(index);// ww  w  . j  av  a 2s . c o m

}

From source file:Main.java

public static void main(String[] argv) {
    StringBuilder sb = new StringBuilder();
    sb.append("java2s.com");

    System.out.println(new String(sb));

}

From source file:Main.java

public static void main(String[] argv) {
    StringBuilder sb = new StringBuilder();
    sb.append("java2s.com");

    sb.reverse();/*from  ww  w .  j  ava  2  s . c o  m*/
    System.out.println(sb.toString());
}

From source file:Main.java

public static void main(String[] argv) {
    StringBuilder sb = new StringBuilder();
    sb.append("java2s.com");

    System.out.println(sb.length());

    System.out.println(sb.capacity());
}