Based on my previous posts related to StringBuffer and StringBuilder let’s see the difference.

StringBuffer StringBuilder
StringBuffer was the only choice for String manipulation till Java 1.4 StringBuilder came into picture from Java 1.5.
all of its public methods are synchronized all of its public methods are not synchronized
StringBuffer provides Thread safety. StringBuilder doesnt provides Thread safety
StringBuilder is slower because of synchronization. StringBuilder is faster and preferred.
Categories: JAVA

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.