Friday, 18 October 2013

remove last characters from a StringBuffer

remove last characters from a StringBuffer
public class StringBufferDelete {
    public static void main(String[] args) {
        String text = "mytechnologythought";
        StringBuffer sb = new StringBuffer(text);
        System.out.println("Original text  = " + sb.toString());
        sb.delete(0, 10);
        System.out.println("After deletion = " + sb.toString());
        sb.deleteCharAt(sb.length() - 1);
        System.out.println("Final result   = " + sb.toString());
    }
}

No comments:

Post a Comment