The answer is NO and NO. With each new your are creating a new object. The == compares for whether operands point to same/different objects. In this case objects are identical but different so answer is NO.
Joined: Sep 10, 2002
i'm sorry I typed wrong thing on. My question is Is sb1.equals(sb2); ? Is s1.equals(s2); ? Thank you very much
Is sb1.equals(sb2); ? No. Because StringBuffer inherites the equals method from Object class which is same as == comparision. As these two different objects, result be false Is s1.equals(s2); ? Yes. Because String overrides the equals method from Object class. String' equals method checks if two string objects have same contents. Hope this helps. Barkat [ September 12, 2002: Message edited by: Barkat Mardhani ]