string buffer capacity
when i run this code the output is that the string buffer capacity is 17 and then after the for loop finishes it's capacity is 36. i know that the capacity changes as the object increases, but i was wondering why it's capacity starts off at 17 and ends at 36.
thanks
class StringBuffer{
static String dupl(String s,int times){
StringBuffer result =new StringBuffer(s);
System.out.println("result.capacity() = "+result.capacity());//17
for (int i=1; i<times; i++){
result.append(s);
}
System.out.println("result.capacity() = "+result.capacity());//36
return result.toString();
}
publicstaticvoid main(String[] args){
System.out.println(dupl("b",20));
}
}
>

