Example usage for java.lang StringBuilder toString

List of usage examples for java.lang StringBuilder toString

Introduction

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

Prototype

@Override
    @HotSpotIntrinsicCandidate
    public String toString() 

Source Link

Usage

From source file:Main.java

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

    double doubleValue = 33.3;
    buffer.insert(0, doubleValue);/*from w ww  .  jav a  2  s.com*/

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

}

From source file:Main.java

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

    Object objectRef = "java2s.com";
    buffer.insert(0, objectRef);/*from w  w  w .  ja  va2 s .c  om*/
    System.out.println(buffer.toString());

}

From source file:Main.java

public static void main(String[] argv) {
    StringBuilder sb = new StringBuilder();
    sb.append(true);/*from w w  w  . j a  v a  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 args[]) {
    StringBuilder buffer = new StringBuilder();

    boolean booleanValue = true;
    buffer.insert(0, booleanValue);/* w w w .  j  av  a  2s  . c  o m*/

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

}

From source file:Main.java

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

    char characterValue = 'K';
    buffer.insert(0, characterValue);// w w  w  .ja  v  a 2  s .c  o m

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

}

From source file:Main.java

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

    char charArray[] = { 'a', 'b', 'c', 'd', 'e', 'f' };
    buffer.insert(0, charArray);/*from ww w .j ava2 s  .co  m*/

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

}

From source file:Main.java

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

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

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

}

From source file:Main.java

public static void main(String[] args) {
    String input = "ThisIsATest";

    // split into words
    String[] words = input.split("(?=[A-Z])");

    words[0] = capitalizeFirstLetter(words[0]);

    // join/*from  www.j a  v  a 2 s.  c o m*/
    StringBuilder builder = new StringBuilder();
    for (String s : words) {
        builder.append(s).append(" ");
    }

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

}

From source file:Main.java

public static void main(String[] a) {
    StringBuilder builder = new StringBuilder("Line 1\n");

    builder.append("Line 3\n");

    builder.insert(0, "Line 2\n");

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

    builder = builder.delete(2, 6);//from   w  ww  .  j a  v  a 2  s . co m

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

}

From source file:Main.java

public static void main(String[] args) {
    String input = "This is a sentence";
    char[] charinput = input.toCharArray();
    Stack<String> stack = new Stack<String>();
    for (int i = input.length() - 1; i >= 0; i--) {
        stack.push(String.valueOf(charinput[i]));
    }/*from   w ww  . ja va 2 s.c  om*/
    StringBuilder StackPush = new StringBuilder();
    for (int i = 0; i < stack.size(); i++) {
        StackPush.append(stack.get(i));
    }
    System.out.println(StackPush.toString());
}