1:54 pm - Tuesday June 27, 2017

StringBuffer example program to delete a range of char

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

 

StringBuffer example program to delete a range of char

Example Program

public class StringBufferDeleteExample {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer("Students");
sb.delete(3, 5); // deletes “den” from the String “students”
System.out.println(sb);
}
}</div>
<div class="toolbar">

Output

   Stunts


Explanation

public StringBuffer delete(int start, int end)

Removes the characters in a substring of this sequence. The substring begins at the specified start and extends to the character at index end – 1 or to the end of the sequence if no such character exists. If start is equal to end, no changes are made.

Parameters:

start – The beginning index, inclusive.

end – The ending index, exclusive.

Returns:

This object.

BACK

Filed in: Z-A All Java Codes

Comments are closed.