 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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 characters in a range from a Java StringBuffer Object
In order to remove characters in a specific range from a Java StringBuffer Object, we use the delete() method. The delete() method removes characters in a range from the sequence. The delete() method has two parameters , start and end. Characters are removed from start to end-1 index.
Declaration − The java.lang.StringBuffer.delete() method is declared as follows −
Let us see a program to delete characters in a specific range from a Java StringBuffer Object.
Example
public class Example {    public static void main(String[] args) {       StringBuffer sb = new StringBuffer("Hello World");       System.out.println("Original StringBuffer Object: " + sb);       sb.delete(4,8);       System.out.println("New StringBuffer Object: " + sb);    } }  Output
Original StringBuffer Object: Hello World New StringBuffer Object: Hellrld
Advertisements
 