Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
If you have a look in the documentation you will find different constructors for String Buffer. * StringBuffer() Constructs a string buffer with no characters in it and an initial capacity of 16 characters. * StringBuffer(CharSequence seq) Constructs a string buffer that contains the same characters as the specified CharSequence. * StringBuffer(int capacity) Constructs a string buffer with no characters in it and the specified initial capacity. * StringBuffer(String str) Constructs a string buffer initialized to the contents of the specified string. https://docs.oracle.com/javase/7/docs/api/java/lang/StringBuffer.html I think only the designer of this class knows why he/she chooses 16. https://coderanch.com/t/455484/java/StringBuffer-size-charectors-java
25th Feb 2019, 11:04 PM
Denise Roßberg
Denise Roßberg - avatar