152. Using 'delete( )' method with StringBuffer

delete( )  method when used with StringBuffer deletes a set of characters from the StringBuffer's object.


StringBuffer object1 = new StringBuffer("ABCD1234EFGH");
object1.delete(4,8); -> Deletes characters from index 4 to index (8-1). i.e. deletes "1234" from "ABCD1234EFGH".

Lets implement this on Eclipse IDE:

1. Create 'deleteDemo' class under any project as shown below:

2. Save and Run the 'deleteDemo' class file
3. Observe that the output is displayed in the console as shown below:

Download this project:

Click here to download the project containing the class file used in this post (You can download this project and import into Eclipse IDE on your machine)

Please comment below to feedback or ask questions.

Using 'deleteCharAt( )' method with StringBuffer will be explained in the next post.

No comments: