public
synchronized StringBuffer insert(int offset, char[] str)
Inserts
the string representation of the char array argument into this
sequence at the position indicated by offset.
public class StringBufferInsertCharArray { public static void main(String args[]){ char c[] = {'H', 'e', 'l', 'l', 'o', ','}; StringBuffer str = new StringBuffer("How are You"); str.insert(0, c); System.out.println("str = " + str); } }
Output
str = Hello,How are You
1. Throws
StringIndexOutOfBoundsException, if the offset is invalid.
No comments:
Post a Comment