Java StringBuffer delete() method removes the characters in a substring of this sequence. The substring begins at the specified start and extends to the character at index end - 1 or to the end of the sequence if no such character exists. If start is equal to end, no changes are made.
Example: Example to delete substring 'java' from string 'javaguides' using delete() method.
public class DeleteExample {
public static void main(String[] args) {
StringBuffer buffer = new StringBuffer("javaguides");
// start with index and end with end -1
StringBuffer subBuffer = buffer.delete(0, 4);
System.out.println("Delete string 'java' from string 'javaguides' : " + subBuffer.toString());
}
}
Output:
Delete string 'java' from string 'javaguides' : guides
Comments
Post a Comment