
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Remove a Character from a Java StringBuffer Object
In order to remove a character from a Java StringBuffer object, we use the deleteCharAt() method. The deleteCharAt() removes the character at the specified index. The length of resultant sequence of characters of the StringBuffer object is reduced by one.
Declaration − The java.lang.StringBuffer.deleteCharAt() method is declared as follows−
public StringBuffer deleteCharAt(int index)
Let us see a program to illustrate the use of the deleteCharAt()
Example
public class Example { public static void main(String[] args) { StringBuffer sb = new StringBuffer("Hello World"); sb.deleteCharAt(7); System.out.println(sb); } }
Output
Hello Wrld
Advertisements