Monday 7 July 2014

insert (int dstOffset, CharSequence s, int start, int end)

public synchronized StringBuffer insert(int dstOffset, CharSequence s, int start, int end)
Inserts a subsequence of the specified CharSequence into this sequence.

dstOffset - the offset in this sequence.
s - the sequence to be inserted.
start - the starting index of the subsequence to be inserted.
end - the end index of the subsequence to be inserted.

public class StringBufferInsertCharSequence {
    public static void main(String args[]){
        CharSequence s = "abHello, ";
        StringBuffer str = new StringBuffer("How are You");
        str.insert(0, s, 2, 9);
        System.out.println("str = " + str);
    }
}

Output
str = Hello, How are You




Prevoius                                                 Next                                                 Home

No comments:

Post a Comment