Java StringBuilder deleteCharAt() Method Example

Java StringBuilder 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 a length().

Java StringBuilder deleteCharAt() Method Example

Example to delete character 'g' from string 'javaguides' using deleteCharAt() method.
public class DeleteCharAtExample {
     public static void main(String[] args) {
         StringBuilder subBuilder = new StringBuilder("javaguides").deleteCharAt(4);
         System.out.println("Delete char 'g' from string 'javaguides' : " + subBuilder1);
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