StringBuffer delete (int start, int end): This method is used to remove a sequence of characters from the StringBuffer object. The start represents the index of the first character to be deleted and end represents the index of one past the last character to remove. Therefore, the deleted substring runs from start to end -1. For example,
StringBuffer s1 = new StringBuffer(“Mr Dinesh Thakur “) :
str.delete(2,9);
results in deleting the substring starting from index 2 to 9 from this string buffer. The string buffer will now contain only “Mr Thakur”.
public class StringBufferDelete
{
public static void main(String[] args)
{
StringBuffer s1 = new StringBuffer("Mr Dinesh Thakur");
s1.delete(2,9);
System.out.println("sl : " + s1);
}
}