Example usage for java.lang StringBuffer capacity

List of usage examples for java.lang StringBuffer capacity

Introduction

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

Prototype

@Override
    public synchronized int capacity() 

Source Link

Usage

From source file:Main.java

public static void main(String[] args) {
    StringBuffer sb = new StringBuffer();
    System.out.println(sb.capacity());
}

From source file:Main.java

public static void main(String[] argv) {
    StringBuffer sb = new StringBuffer(20);
    System.out.println(sb.capacity());
}

From source file:MainClass.java

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

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

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 newString = new StringBuffer("abcde");

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

    newString.ensureCapacity(40);//from   ww w.  j av  a  2s  .  c  o  m

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

From source file:MainClass.java

public static void main(String args[]) {
    StringBuffer sb = new StringBuffer("Hello");
    System.out.println("capacity = " + sb.capacity());
}

From source file:MainClass.java

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

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

    newString.setLength(8);// ww  w . j ava  2 s.  c  o  m

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

}

From source file:Main.java

public static void main(String args[]) {
    StringBuffer sb = new StringBuffer();
    sb.ensureCapacity(100);/*from   www . j av  a2 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[] 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[] argv) {
    StringBuffer sb = new StringBuffer();
    sb.append("java2s.com");

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

    sb.trimToSize();//from  w w w .j  av a  2s  . c  om

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

}