Example usage for java.lang StringBuffer toString

List of usage examples for java.lang StringBuffer toString

Introduction

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

Prototype

@Override
    @HotSpotIntrinsicCandidate
    public synchronized String toString() 

Source Link

Usage

From source file:MainClass.java

public static void main(String args[]) {
    StringBuffer sb = new StringBuffer(40);
    sb.append(5);/*from  ww  w  .  j  a v  a  2 s  .  co  m*/
    String s = sb.toString();
    System.out.println(s);
}

From source file:Main.java

public static void main(String[] argv) {
    StringBuffer sb = new StringBuffer();
    sb.append(1.2);/* w ww . j  a v a2 s .c  o  m*/
    System.out.println(sb.toString());
}

From source file:Main.java

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

From source file:Main.java

public static void main(String[] argv) {
    StringBuffer sb = new StringBuffer();
    sb.append(true);/*  w  ww. ja v a 2 s. c o m*/
    System.out.println(sb.toString());
}

From source file:MainClass.java

public static void main(String[] arg) {
    StringBuffer palindrome = new StringBuffer("so many dynamos");

    String aString = palindrome.toString();

    System.out.println(aString);//from   ww  w.  ja va  2  s.  c o  m

}

From source file:Main.java

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

From source file:Main.java

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

    System.out.printf("buffer = %s\n", buffer.toString());
    System.out.printf("Character at 0: %s\nCharacter at 4: %s\n\n", buffer.charAt(0), buffer.charAt(4));

    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[] argv) {
    StringBuffer sb = new StringBuffer();
    sb.append("java2s.com");

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

From source file:MainClass.java

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

    System.out.printf("buffer = %s\n", buffer.toString());
    System.out.printf("Character at 0: %s\nCharacter at 4: %s\n\n", buffer.charAt(0), buffer.charAt(4));

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

    for (char character : charArray)
        System.out.print(character);

    buffer.setCharAt(0, 'H');
    buffer.setCharAt(6, 'T');
    System.out.printf("\n\nbuf = %s", buffer.toString());

    buffer.reverse();/*from  w  w  w  . j a  v  a 2 s  . c  o m*/
    System.out.printf("\n\nbuf = %s\n", buffer.toString());
}

From source file:Main.java

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

    int integerValue = 7;
    buffer.insert(0, integerValue);// w w  w .  j av a 2s.  c  o m

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

}