StringBuilder In Java with Example

StringBuilder is mutable sequence of characters. It can store character, append character, delete character easily. StringBuilder should not use in multi thread program, it is not synchronized. It is good to use in single thread programs. It is faster than Stringbuffer.
Use of StringBuilder in java is shown below.

Example of StringBuilder in java

public class StringBuilderExample {

    public static void main(String[] args) {

        StringBuilder sb = new StringBuilder();

        sb.append("Java Stringbuilder");

        System.out.println("StringBuilder1 :"+sb);

        sb.append(" Example");

        System.out.println("StringBuilder2 :"+sb);

StringBuilder1 :Java Stringbuilder
StringBuilder2 :Java Stringbuilder Example

Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email