Java StringBuffer deleteCharAt() Example

Java StringBuffer deleteCharAt() method removes the char at the specified position in this sequence. This sequence is shortened by one char.
This method throws StringIndexOutOfBoundsException - if the index is negative or greater than or equal to length().

Java StringBuffer deleteCharAt() Example

Example: Example to delete character 'g' from string 'javaguides' using deleteCharAt() method.
public class DeleteCharAtExample {
    public static void main(String[] args) {
        StringBuffer buffer = new StringBuffer("javaguides").deleteCharAt(4);
        System.out.println("Delete char 'g' from string 'javaguides' : " + buffer);
Delete char 'g' from string 'javaguides' : javauides

Free Spring Boot Tutorial - 5 Hours Full Course

Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course