VOOZH about

URL: https://www.geeksforgeeks.org/java/java-stringbuilder-delete-int-start-int-end-method/

⇱ Java StringBuilder delete(int start, int end) Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Java StringBuilder delete(int start, int end) Method

Last Updated : 23 Jul, 2025

delete(int start, int end) method in the StringBuilder class is used to remove a portion of the string, starting from the specified start index to the specified end index. This method is used to modify mutable sequences of characters.

Example 1: The below example demonstrates how to use the delete() method to remove a substring from a given start index to an end index.


Output
Hello, !

Syntax of StringBuilder delete() Method

public StringBuilder delete(int start, int end)

Parameters:

  • start: It is beginning index from where the deletion will start. The character in the start index is included.
  • end: The ending index where the deletion will stop. The character in the end index is excluded.

Return Value: It returns the StringBuilder object after deleting the specified portion of the string.

Example 2: Here, we use the delete() method to delete a substring from a string between a start index and an end index.


Output
Javang

Example 3: Here, we use delete() method to delete a substring from a specific index to the end of the string.


Output
Hello, 

Example 4: Here, we use delete() to delete the substring from the start of the string to a specific index in the middle.


Output
 the first part
Comment
Article Tags: