Search code examples
javastringbuilderstringbuffer

Using StringBuffer in single thread applications


Is there a reason to use StringBuffer in a single-threaded applications instead of a StringBuilder? Are there any advantages of StringBuffer if we do not count synchronization in applications using multiple threads?


Solution

  • Only reason I can think of is compatibility with pre-1.5 Java (which might still be in use in some larger companies), and code that is to be shared with other platforms that do not support StringBuilder (ie. CLDC).