Java Review: StringBuilder & StringBuffer
StringBuilder and StringBuffer provide mutable access to a string type variable. The buffer is synchronized, making it safe for multithreaded use. In most un-threaded cases, StringBuilder is preferred as it is faster than the Buffer due to lack of synchronization.
To use one of these objects, instantiate as follows-
StringBuilder/StringBuffer mySB = new StringBuilder/StringBuffer(str) mySB;
Common methods for both the String builder and buffer include:
append(example)- add almost anything to the string. String, int, float, long, etc.
delete(startIndex, endIndex)
deleteCharAt(index)
reverse()
length()
insert(offset, string)
toString()