StringBuffer sb1 = new StringBuffer("Test"); StringBuffer sb2= new StringBuffer("Test"); If (sb1.equals(sb2)) -- returns false. I am unable to understand why it returns false. I thought that sb1 and sb2 are objects so it would return "true". Can anyone explain me where I am wrong and also about (sb1 == sb2). Thanks
I went and looked at the source for StringBuffer. It doesn't implement the equals() method. So you only have the default method in Object which does nothing more than see if the two references are the same (which happens to be the same thing that == does).