public class MainClass { 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); System.out.println(newString.capacity()); System.out.println(newString.length()); System.out.println(newString); } }
31 15 abcde1234567890 31 8 abcde123