Dave's Brain

Browse - Programming Tips - Should I use StringBuffer or StringBuilder?

Date: 2011sep28
Updated: 2014mar24
Language: Java

Q.  Should I use StringBuffer or StringBuilder?

A.  Unless you need the buffer to be thread-safe use StringBuilder --
its is faster.

Also if you want to use Matcher's appendReplacement() and appendTail()
you need to use StringBuffer.

But usually you just want something faster than string + string
so use StringBuilder.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.