public class StringBufferDeleteCharacters
{
public static void main(String surat[])
{
StringBuffer sb = new StringBuffer("Mahi");
System.out.println("Original text: " + sb);
sb.delete(0, 2);
System.out.println("Current text: " + sb);
sb.deleteCharAt(sb.length()-1);
System.out.println("Current text: " + sb);
}
}
Output:
{
public static void main(String surat[])
{
StringBuffer sb = new StringBuffer("Mahi");
System.out.println("Original text: " + sb);
sb.delete(0, 2);
System.out.println("Current text: " + sb);
sb.deleteCharAt(sb.length()-1);
System.out.println("Current text: " + sb);
}
}
Output:
No comments:
Post a Comment