java tutorial - Java StringBuffer delete() method - java programming - learn java - java basics - java for beginners



Java  stringbuffer delete

Learn Java - Java tutorial - Java stringbuffer delete - Java examples - Java programs

Description

  • The delete () method — deletes characters in the substring of this buffer string ( StringBuffer ). The substring starts at the specified start index and extends to the end-index character, or to the end of the StringBuffer , if such a character does not exist.
  • In other words, the method allows you to delete characters from a string, starting and ending with the specified indexes.

If start (initial index) is equal to end (end index), then no changes are made.

Syntax

Syntax method:

public StringBuffer delete(int start, int end)
click below button to copy the code. By - java tutorial - team

Options

Detailed information about the parameters:

  • start - initial index, inclusive;
  • end - end index, not including.

Return value

  • In Java, delete () returns a buffer string object ( StringBuffer ).

Sample Code

public class Test {

public static void main (String args []) {
StringBuffer sb = new StringBuffer ("wikitechy");
sb.delete (5,8);
System.out.println (sb);
}
}
click below button to copy the code. By - java tutorial - team

Output

wikity

Related Searches to Java StringBuffer delete() method