append(String str) StringBuffer method in java

append(String str): append the specified string at the end of this string.


public synchronized StringBuffer append(String str)

Note: if specified string is null than it append “null” string at the end.
If append has object, int, double etc as an argument than argument value first converted into string using String.valueOf()before appending.


 * This program is used to show the use of append() method.
 * @author w3spoint
class TestStringBuffer{
	StringBuffer sb = new StringBuffer("Hello ");
	 * This method is used to show the use of append() method.
	 * @author w3spoint
	public void appendTest(){
		//concatenate the argument string 
                //at the end of this string.
public class StringBufferAppendExample {
	public static void main(String args[]){
		//creating TestStringBuffer object
		TestStringBuffer obj = new TestStringBuffer();
		//method call



Download this example.
Next Topic: insert(int offset, String str) StringBuffer method in java.
Previous Topic: StringBuffer in java.


Please Share