Example & Tutorial understanding programming in easy ways.

What StringBuilder method in java used?.

Here some important StringBuilder Method in java are given bellow:

                                             Methods                    Description
public int capacity()  it is used to return the current capacity.
public StringBuilder append(String s) it  is used to append the specified string with this string. The append() method is overloaded like append(char), append(boolean), append(int), append(float), append(double) etc.
public StringBuilder delete(int startIndex, int endIndex):
it is used to delete the string from specified startIndex and endIndex.
 
public StringBuilder reverse()
 
 it is used to reverse the string.
public StringBuilder insert(int offset, String s)
 
it  is used to insert the specified string with this string at the specified position. The insert() method is overloaded like insert(int, char), insert(int, boolean), insert(int, int), insert(int, float), insert(int, double) etc.
public StringBuilder replace(int startIndex, int endIndex, String str):
 
it is used to replace the string from specified startIndex and endIndex.

public int length()
 
it is  used to return the length of the string i.e. total number of characters.
 
public String substring(int beginIndex)
it is used to return the substring from the specified beginIndex
public String substring(int beginIndex, int endIndex)  it is used to return the substring from the specified beginIndex and endIndex.
public char charAt(int index) it  is used to return the character at the specified position.
public void ensureCapacity(int minimumCapacity)  it is used to ensure the capacity at least equal to the given minimum.


 

Read More →