Java StringBuffer class
Java StringBuffer class is used to create mutable (modifiable) string. The StringBuffer class in java is same as String class except it is mutable i.e. it can be changed .
Important methods of StringBuffer class
append(String s) |
is used to append the specified string with this
string. |
insert(int offset, String s) |
is used to insert the specified string with this
string at the specified position. |
replace(int startIndex, int endIndex,
String str) |
is used to replace the string from
specified startIndex and endIndex. |
delete(int startIndex,
int endIndex) |
is used to delete the string from
specified startIndex and endIndex |
reverse() |
is used to reverse the string |
charAt(int
index)
|
is used to return the character at the specified
position. |
length() |
is used to return the length of the string i.e.
total number of characters. |
Java StringBuilder class
Java StringBuilder class is used to create mutable (modifiable) string. The Java StringBuilder class is same as StringBuffer class except that it is non-synchronized.
Important methods of StringBuilder class
public StringBuilder append(String s) |
is used to append the specified string with
this string. |
public StringBuilder insert(int offset,
String s) |
is used to insert the specified string with
this string at the specified position.. |
public StringBuilder replace(int startIndex,
int endIndex, String str) |
is used to replace the string from specified
startIndex and endIndex. |
public StringBuilder delete(int startIndex,
int endIndex) |
is used to delete the string from specified
startIndex and endIndex. |
public StringBuilder reverse() |
is used to reverse the string. |
public char charAt(int index) |
is used to return the character at the
specified position. |
public int length() |
is used to return the length of the string
i.e. total number of characters. |
0 Comments