by Dinesh Thakur Category: array

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'};


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'};
            System.out.println("s2 : " + s2);

StringBuffer append()methods in Java Example

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles