Akshay Rawal wrote:
Paul Clapham wrote:The documentation for that method says that 5 characters and 3 characters will be appended by your two examples respectively (take a minute and check it out). Since the StringBuilder is initially empty (as far as I can tell), it would follow that the results would contain 5 characters and 3 characters respectively, no?
...ok thanks i got it...5 and 3 are length ..
...this
string is eating enough of my brain..one more confusion..
String s1 = new String("gg");
String s2 = new String("gg");
s1.equals(s2)//true...i understood....now
StringBuffer sb1 = new StringBuffer("hi");
StringBuffer sb2 = new StringBuffer("hi");
StringBuffer sb3 = new StringBuffer(sb2);
StringBuffer sb4 = sb3 ;
System.out.println(sb1.equals(sb2));//false...why...are they comparing reference or string value
System.out.println(sb4.equals(sb3));//true...why...confused