by Dinesh Thakur Category: array

StringBuffer delete (int start, int end): This method is used to remove a sequence of characters from the StringBuffer object. The start represents the index of the first character to be deleted and end represents the index of one past the last character to remove. Therefore, the deleted substring runs from start to end -1. For example,

StringBuffer s1 = new StringBuffer("Mr Dinesh Thakur ") :

str.delete(2,9);

results in deleting the substring starting from index 2 to 9 from this string buffer. The string buffer will now contain only "Mr Thakur".

public class StringBufferDelete

{
          public static void main(String[] args)
      {
             StringBuffer s1 = new StringBuffer("Mr Dinesh Thakur");
             s1.delete(2,9);
             System.out.println("sl : " + s1);
       }
}

StringBuffer delete() Method in Java Example

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content





Popular Article