what is the difference between the StringBuffer vs StringBuilder Vs StringTokenizer on the internal implementation. when to use these . kindly waiting for the answer.
Update:-
I am also going through the source code.
what is the difference between the StringBuffer vs StringBuilder Vs StringTokenizer on the internal implementation. when to use these . kindly waiting for the answer.
I am also going through the source code.
StringBuffer - introduced in JDK 1.0 - is thread safe (all of its methods are synchronized), while StringBuilder - since JDK 1.5 - is not. Thus it is recommended to use the latter under normal circumstances.
StringTokenizer is meant for a whole different purpose then the former two: cutting strings into pieces, rather than assembling. As @Henning noted, it is also "retired" since JDK 1.5 - it is recommended to use String.split instead.
StringTokenizer, while not deprecated, is also a "legacy class that is retained for compatibility reasons although its use is discouraged in new code". download.oracle.com/javase/6/docs/api/java/util/…StringBuffer is designed to be thread-safe and all public methods in StringBuffer are synchronized. StringBuilder does not handle thread-safety issue and none of its methods is synchronized.
StringBuilder has better performance than StringBuffer under most circumstances.
Use the new StringBuilder wherever possible.
Here is performance comparison of StringBuilder & StringBuffer
StringBuilder & StringBuffer Holds String where StringoTokeizer class allows an application to break a string into tokens .. So It is like odd one out
StringBuffer - is synchronized version of StringBuilder (introduced after its unsynchronized peer)