Example usage for java.lang StringBuffer StringBuffer

List of usage examples for java.lang StringBuffer StringBuffer

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public StringBuffer() 

Source Link

Document

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

Usage

From source file:Main.java

public static void main(String[] argv) {
    StringBuffer sb = new StringBuffer();
    sb.append(true);/*from  w w w  . ja va 2 s  .c  o m*/
    sb.append("java2s.com");

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

From source file:Main.java

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

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

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

From source file:Main.java

public static void main(String args[]) {
    StringBuffer sb = new StringBuffer();
    sb.ensureCapacity(100);//from w  w w  . j  a  v  a 2  s  .c  om
    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[]) {
    StringBuffer buffer = new StringBuffer();

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

}

From source file:Main.java

public static void main(String[] arg) {

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

From source file:Main.java

public static void main(String[] arg) {

    StringBuffer buffer = new StringBuffer();
    char[] chars = new char[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' };
    buffer.append(chars, 1, 3);//www .  ja va  2  s  . c  om
    System.out.println(buffer);
}

From source file:Main.java

public static void main(String[] arg) {

    StringBuffer buffer = new StringBuffer();
    CharSequence cs = "java2s.com";
    buffer.append(cs);/*  www .j  a  v a  2  s  .  co  m*/
    System.out.println(buffer);
}

From source file:Main.java

public static void main(String[] arg) {

    StringBuffer buffer = new StringBuffer();
    CharSequence cs = "java2s.com";
    buffer.append(cs, 1, 2);//w w w  .j a  va 2 s.c  o m
    System.out.println(buffer);
}

From source file:Main.java

public static void main(String[] arg) {

    StringBuffer buffer = new StringBuffer();
    float f = 123.45F;
    buffer.append(f);// w  w  w  . j ava2s  .  c o m
    System.out.println(buffer);
}

From source file:Main.java

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

    char charArray[] = { 'a', 'b', 'c', 'd', 'e', 'f' };
    buffer.insert(0, charArray);/*from  www .j  a  v  a2  s  .c o m*/

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

}