StringBuffer sb = new StringBuffer("Hello World"); sb.deleteCharAt(6); System.out.println(sb); // Output: Helloorld
StringBuffer sb1 = new StringBuffer("This is a test."); while (sb1.indexOf("t") != -1) { sb1.deleteCharAt(sb1.indexOf("t")); } System.out.println(sb1); // Output: his is a es.In this example, the `deleteCharAt()` method is used inside a `while` loop to remove all occurrences of the character `t` from the `StringBuffer` object `sb1`. The `deleteCharAt()` method belongs to the `java.lang` package.