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(true);// w w w  .j  ava 2 s  .com
    sb.append("java2s.com");

    sb.delete(1, 2);
    System.out.println(sb.toString());
}

From source file:Main.java

public static void main(String args[]) {
    StringBuilder sb = new StringBuilder();
    sb.ensureCapacity(100);//  w  w w  . j a  v a 2 s .c  o  m
    sb.append("java2s.com");
    System.out.println(sb.capacity());
    System.out.println(sb.length());
    System.out.println(sb.toString());

}

From source file:Main.java

public static void main(String args[]) {
    StringBuilder buffer = new StringBuilder();

    Object objectRef = "java2s.com";
    buffer.insert(0, objectRef);//w  ww  .  j ava2 s  .  co m
    System.out.println(buffer.toString());

}

From source file:Main.java

public static void main(String[] arg) {

    StringBuilder buffer = new StringBuilder();
    char[] chars = new char[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' };
    buffer.append(chars, 1, 3);//from www.j  av a 2 s  .co m
    System.out.println(buffer);
}

From source file:Main.java

public static void main(String[] arg) {

    StringBuilder buffer = new StringBuilder();
    CharSequence cs = "java2s.com";
    buffer.append(cs, 1, 2);//from ww  w  .ja  v a 2 s  .c  o m
    System.out.println(buffer);
}

From source file:Main.java

public static void main(String[] arg) {

    StringBuilder buffer = new StringBuilder();
    char[] chars = new char[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' };
    buffer.append(chars);//w w  w  . jav a 2 s  .c o m
    System.out.println(buffer);
}

From source file:Main.java

public static void main(String[] arg) {

    StringBuilder buffer = new StringBuilder();
    CharSequence cs = "java2s.com";
    buffer.append(cs);/*from   w ww  . j av  a  2 s .c om*/
    System.out.println(buffer);
}

From source file:Main.java

public static void main(String[] arg) {

    StringBuilder buffer = new StringBuilder();
    float f = 123.45F;
    buffer.append(f);//  w  w w . j  av a 2 s.  co m
    System.out.println(buffer);
}

From source file:Main.java

public static void main(String args[]) {
    StringBuilder buffer = new StringBuilder();

    long longValue = 10000000;
    buffer.insert(0, longValue);//from   w  w w  .  j a  v a2s  .  co  m

    System.out.println(buffer.toString());

}

From source file:Main.java

public static void main(String args[]) {
    StringBuilder buffer = new StringBuilder();

    boolean booleanValue = true;
    buffer.insert(0, booleanValue);/*from   w ww  . j  a va2  s . com*/

    System.out.println(buffer.toString());

}