I'm a
Java Newbie, so this may - or may not - be correct, but....
You asked:
why is the output false for (sb1.equals(sb2)) and (sb1.equals(ss1)) The equals() method would only return true if sb1 and sb2 refer to the same object. But they don't. While the letters ("Amit") may be the same, sb1 and sb2 actually occupy different memory locations.
The same is true with sb1 and ss1. They're in different memory locations.
Senthil's reply, as Samith said, explains this very well: The String class overrides the equals() method, so that if 2 Strings have the same contents, the result is 'true'. But the StringBuffer class doesn't offer this override, so the result is 'false'.
Susan
[This message has been edited by Susan Delph (edited April 28, 2001).]