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.
up down, Welcome to JavaRanch! We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy. Thanks Pardner! Hope to see you 'round the Ranch!
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 ]