3:11 pm - Monday November 23, 6443

Append two String using StringBuffer append() Method

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

 

                                   In this tutorial you will learn how to append two String Using StringBuffer append Method with Example program.

public class StringBufferAppendExample {
	public static void main(String[] args) {
		StringBuffer sb = new StringBuffer("STUDENT");
		sb.append(" MARKLIST");
		System.out.println(sb);
	}
}

Output

STUDENTNAMELIST

 

Explanation:

public StringBuffer append(String str)

Appends the specified string to this character sequence.

The characters of the String argument are appended, in order, increasing the length of this sequence by the length of the argument.

If str is null, then the four characters “null” are appended.

Let n be the length of this character sequence just prior to execution of the append method. Then the character at index k in the new character sequence is equal to the character at index k in the old character sequence, if k is less than n; otherwise, it is equal to the character at index k-n in the argument str.

Parameters:

str – a string.

Returns:

a reference to this object.

 

BACK

Filed in: Java Examples

Comments are closed.