String Buffer

In Java, StringBuffer class is used to create mutable string. It means we can modify or change in the existing String. Java StringBuffer class is also thread i.e. multiple threads can not access it simultaneously.

StringBuffer Constructors:

1. StringBuffer(): It reserves initial capacity of 16 characters as an empty string.

For ex:
StringBuffer s=new StringBuffer();

2. StringBuffer(int size): It reserves capacity of specified length as an empty string.

For ex:
StringBuffer s=new StringBuffer(20);

3. StringBuffer(String str): It accepts a String argument with the specified string

For ex:
StringBuffer s=new StringBuffer(“Welcome in hugelearning.com”);