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");


Leave a Reply

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

Pin It on Pinterest

Share This

Share this post with your friends!