Java-StringBuffer

StringBuffer The StringBuffer class is the companion class of the String class. The objects of the String class represent fixed-length, immutable character sequences. On the other hand, the objects of the StringBuffer class represent growable and mutable character sequences. The methods that are available in the StringBuffer class make it possible to insert a substring … Read more…

Java-Extracting Character

Extracting Character The charAt( ) method of StringBuffer class enables us to extract at the specified index position. For example, in the following program, the character at the index position ‘3’ in the string “ABCDE” is ‘D’, the output statement will return the character ‘D’. The setCharAt( ) method of StringBuffer class enables us to … Read more…

Java-Insert

Insert The insert( ) method is a companion method of the append( ) method. While the append( ) method enables us to add a new string only at the end of an existing string, the insert( ) method helps us to add a new string from any specified position in the existing string. For example, … Read more…

Java-Reverse and Replace

reverse You can reverse the characters with in a StrngBuffer object using reverse() method. This method returns the reversed object. replace You can replace one set of characters with another set inside a StringBuffer object by calling replace(int startIndex, int endIndex, String str). The substring being replaced is specified by the indexes startIndex and endIndex. Thus, … Read more…