- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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
- Related Articles
- Remove characters in a range from a Java StringBuffer Object
- Change a single character in a Java StringBuffer object in Java
- Get the length of a StringBuffer Object in Java
- How to remove the last character from a string in Java?
- What is the difference between a String object and a StringBuffer object in java?
- Set the capacity value for a StringBuffer object in Java
- Call append() method to construct a StringBuffer object in Java
- How to remove a particular character from a String.
- Reverse the sequence of characters in a StringBuffer Object in Java
- Creating String Object from certain part of a character Array in Java
- Java Program to remove a character at a specified position
- Creating String Object from Character Array in Java
- Create a StringBuffer object using a reference stored in a variable of type String in Java
- How to remove a property from a JavaScript object?
- C# program to remove n-th character from a string

Advertisements