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

public StringBuffer(CharSequence seq) 

Source Link

Document

Constructs a string buffer that contains the same characters as the specified CharSequence .

Usage

From source file:Main.java

public static void main(String args[]) {
    StringBuffer buffer = new StringBuffer("hello there from java2s.com");

    char charArray[] = new char[buffer.length()];
    buffer.getChars(0, buffer.length(), charArray, 0);
    System.out.print("The characters are: ");

}

From source file:Main.java

public static void main(String[] args) {
    StringBuffer sb = new StringBuffer("this is a test");
    System.out.println(sb);//from  w w w. j a v a2  s .co  m
    sb.reverse();
    System.out.println(sb);

}

From source file:Main.java

public static void main(String[] arg) {

    StringBuffer buffer = new StringBuffer("from java2s.com");
    CharSequence cs = "java2s.com";
    buffer.insert(2, cs, 1, 3);/*from  w  w  w  . j a  v  a2  s  .c o m*/
    System.out.println(buffer);
}

From source file:Main.java

public static void main(String[] arg) {

    StringBuffer buffer = new StringBuffer("from java2s.com");
    CharSequence cs = "java2s.com";
    buffer.insert(2, cs);//from   ww  w.  ja 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("from java2s.com");

    buffer.append(buffer);/* www . j a v  a2s .com*/

    System.out.println(buffer);
}

From source file:MainClass.java

public static void main(String[] arg) {
    StringBuffer phrase = new StringBuffer("one two three four");
    int position = phrase.lastIndexOf("three");

    System.out.println(position);
}

From source file:Main.java

public static void main(String[] arg) {

    StringBuffer buffer = new StringBuffer("from java2s.com");

    buffer.appendCodePoint(66);/*from  w  w w .j  a v a2  s.  co m*/

    System.out.println(buffer);
}

From source file:MainClass.java

public static void main(String[] arg) {
    StringBuffer phrase = new StringBuffer("one two three four");
    int position = phrase.lastIndexOf("three", 6);

    System.out.println(position);
}

From source file:MainClass.java

public static void main(String[] arg) {
    StringBuffer newString = new StringBuffer("abcde");

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

From source file:MainClass.java

public static void main(String[] arg) {
    StringBuffer aString = new StringBuffer("ABCDE");

    int length = aString.length();
    System.out.println(length);/*from ww w .j av a 2 s.  c o m*/
}