Please enable JavaScript.
Coggle requires JavaScript to display documents.
Using the StringBuilder Class (StringBuilder methods (charAt(index):char,…
Using the StringBuilder Class
StringBuilder is not immutable
append()
concatena a string without create new object
creating StringBuilder
StringBuilder sb1 = new StringBuilder();
Create empty string
StringBuilder sb3 = new StringBuilder(10);
create with reserved slots
StringBuilder sb2 = new StringBuilder("animal");
create with string
Mutability and Chaining
be careful in chaining StringBuilder methods
StringBuilder are mutable
append() concat string in the same object
StringBuilder methods
charAt(index):char
indexOf(String):int
length():int
substring(startIndex, endIndex):String
substring(startIndex):String
append(many data types):StringBuilder
delete(startIndex, endIndex):StringBuilder
deleteCharAt(index):StringBuilder
toString():String
insert();
Tips
working on insert
draw what is going on