StringBuilder class in Java 5.0


StringBuilder class is introduced in Java 5.0 version. This class is replacement for the
existing StringBuffer class. If you look into the operations of the both the classes,
there is no difference.

also read:

  • If you are using StringBuilder, no guarantee of synchronization. This is the only difference with StringBuffer class.
  • It is recommended that this class be used in preference to StringBuffer as it will be faster.
  • You can easily replace the exisitng StringBuffer implementaion with StringBuilder without any compilation


 * source :
public class StringBuilderExample {
 public static void main(String[] args) {
 StringBuilder stringBuilder = new StringBuilder();
 stringBuilder.append("Add a string");




About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.