in terms of diagram we can have like this
System.out.println("in append method");//insert this line will make it more clear
System.out.println(sb1 + "," + sb2);
prints bb,bb(because value for duplicates is getting printed pattern)
but in original it will prints sb1=ab and sb2=bb..