In Java String are immutable, so we use String Buffer classes to make necessary changes in string objects. With the help of String Buffer Class we can alter, concat and modify string object again without even creating a lot of unused objects.
We can initialize a string buffer by StringBuffer() Class →
StringBuffer sb = new StringBuffer("JAVA CODE ");
String Buffer provide methods to alter the string; some of the methods are listed below→
The Append method is use to append the string at the end of an existing string buffer
The insert method is used to insert character sequence to the string buffer by any index, so it take two argument first is the index and second argument is the character sequence.
the delete method in string buffer is used to remove character from string based on start index and end index, it take two argument both index and return removed carachter from startindex to endindex-1
The reverse method returns the existing string but in reverse order of index.