Created
August 23, 2016 14:34
-
-
Save anonymous/8458cd71e8de262c8fdfb525b6f06911 to your computer and use it in GitHub Desktop.
how come the capacity remains same after the third append?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Sb1{ | |
public static void main(String[] args){ | |
StringBuffer sb=new StringBuffer(); | |
System.out.println(sb.capacity()); | |
System.out.println(sb.length()); | |
StringBuffer sb1=sb.append("abcdefghijklmnopqrstuvwxyzabcdefghijk"); | |
System.out.println("after first append"); | |
System.out.println(sb.capacity()); | |
sb.append("q"); | |
System.out.println("after second append"); | |
System.out.println(sb.capacity()); | |
sb.append("p"); | |
System.out.println("after third append"); | |
System.out.println(sb.capacity()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment