<<< StringBuilder substring( ) example | Index | StringBuilder length( ), setLength( ), capacity( ) methods >>> |
Code that shows how capacity automatically increases:
StringBuilder name = new StringBuilder( 8 ); int capacity1 = name.capacity(); // capacity1 is 8 name.append( "Raymond R. Thomas" ); int length = name.length(); // length is 17 int capacity2 = name.capacity(); // capacity2 is 18 // (2 * capacity1 + 2)
<<< StringBuilder substring( ) example | Index | StringBuilder length( ), setLength( ), capacity( ) methods >>> |