by Dinesh Thakur

StringBuffer append(char[] str,int offset,int len) :This method appends the substring to the end of the string buffer. The substring appended is a character sequence beginning at the index offset with the number of characters appended equal to len of the character array str. For example,

char [] chArr = {, t' ,'o' " ',' J' ,'a','v','a'};

s1.append(chArr,2,5);

willl append' ',' J' ,'a','v','a' characters at the end of the string "Welcome", which results in "Welcome Java".

public class StringBufferAppendMethod

{
       public static void main(String[] args)
     {
            StringBuffer s1 = new StringBuffer("Welcome");
            s1.append(" Dinesh Thakur");
            System.out.println("s1 : " +s1);
            s1.append(" ").append("to").append(" Home").append("!");
            System.out.println("s1 : " +s1);
            StringBuffer s2 = new StringBuffer("Welcome");
            char[] chArr = {'t','o',' ','j','a','v','a'};
            s2.append(chArr,2,5);
            System.out.println("s2 : " + s2);
      }
}

StringBuffer append()methods in Java Example