public
synchronized StringBuffer deleteCharAt(int index)
Removes
the char at the specified position in this sequence.
public class StringBufferDelectCharAt { public static void main(String args[]){ StringBuffer str1 = new StringBuffer("Hi How are you"); System.out.println("str1 before calling delete method"); System.out.println(str1); System.out.println("str1 after calling deleting spaces"); str1.deleteCharAt(2); str1.deleteCharAt(5); str1.deleteCharAt(8); System.out.println(str1); } }
Output
str1 before calling delete method Hi How are you str1 after calling deleting spaces HiHowareyou
1. Throws
StringIndexOutOfBoundsException if the index is negative or greater
than or equal to length().
No comments:
Post a Comment