The methods
delete and deleteCharAt are used for deleting a character or a sequence of characters with in a StringBuffer .
The Syntax for
delete is:
StringBuffer delete(int startIndex, int endIndex)
This method is used for deleting a sequence of characters within a StringBuffer . Here startIndex specifies the starting index of character which you want to delete and endIndex specifies an index one past the last character to remove. This method deletes the substring from startIndex to endIndex - 1 and the resulting StringBuffer object is returned.The method for deleteCharAt is:
StringBuffer deleteCharAt(int loc)
This method is used to delete a single character at an index (loc ). The resulting StringBuffer object is returned.Here is the example program to demonstrate delete, deleteCharAt :
StringBufferdelete and deleteCharAt Demo CODE class StringBufferDeleteExample OUTPUT Bharat DESCRIPTION This program shows how to delete a character or set of characters from a THINGS TO TRY
Dependent Topics :
|