mutable string in Java

The StringBuilder is a mutable string in Java. 
```
public class Main {
    public static void main(String[] args) {
        StringBuilder a = new StringBuilder("abc");
        StringBuilder b = a.append("de");
        b = b.append("f").append("g");
        System.out.println("a=" + a); //a=abcdefg
        System.out.println("b=" + b); //b=abcdefg
    }
}
```
The function of StringBuilder is similar to the StringBuffer class. However the StringBuilder class provides no guarantee of synchronization whereas the StringBuffer class does. Instances of StringBuilder are not safe for use by multiple threads. If such synchronization is required then it is recommended that StringBuffer be used.
Some stringBuild method,
Name | Meaning
----- | -----
StringBuilder append(String str) | Adds the parameter to the StringBuilder and returns a ref-erence to the current StringBuilder.
int capacity() | The logic behind the capacity function: <br>If you don't initialize stringbuilder with any content, default capacity will be taken as 16 characters capacity. <br>If you initialize stringbuilder with any content, then capacity will be content length+16. <br>When you add new content to stringbuilder object, if current capacity is not sufficient to take new value, then it will grow by (previous array capacity+1)*2.
char charAt(int index) | Returns the character at the specified index.
StringBuilder delete(int start, int end) | Removes characters from the sequence and returns a reference to the current StringBuilder
StringBuilder deleteCharAt(int index) | Delete only one character.
int length() | Returns the length of this string.
int indexOf(char ch)<br>int indexOf(char ch, index fromIndex)<br>int indexOf(String str)<br>int indexOf(String str, index fromIndex) | Returns the index within this string of the first occurrence of the specified substring.
StringBuilder insert(int offset, String str) | Adds characters to the StringBuilder at the requested index and returns a reference to the current StringBuilder. 
StringBuilder reverse() | Reverses the characters in the sequences and returns a reference to the current StringBuilder. 
String substring(int beginIndex)<br>String substring(int beginIndex, int endIndex)  | Returns a new string that is a 
String toString() | Converts a StringBuilder into a String.


```
public class Main {
    public static void main(String[] args) {
        StringBuilder sb1 = new StringBuilder(10);
        System.out.println(sb1.capacity());  // 10
        StringBuilder sb2 = new StringBuilder("abc"); 
        System.out.println(sb2.capacity()); // 19 = 16 + 3
        StringBuilder sb3 = new StringBuilder();
        System.out.println(sb3.capacity()); //16
    }
}
```