Java StringBuilder append() method

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


public StringBuilder append(String str)


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


StringBuilder append() Example

class TestStringBuilder{
    StringBuilder sb = new StringBuilder("Hello ");

    public void appendTest(){
        //concatenate the argument string 
                //at the end of this string.

public class StringBuilderAppendExample {
    public static void main(String args[]){
        //creating TestStringBuilder object
        TestStringBuilder obj = new TestStringBuilder();
        //method call