Originally posted by Sagar Bilgi:
Yeah gaurav, I know that but arent we comparing the same object?? ie b1 ..
No, you are not comparing the same object.
The toString() method is overriden in Byte class to return a new
String.
So the if clause
if(b1.toString() == b1.toString())
creates two
differentobjects because toString() is called twice.
Hence == will return False.
The contents of the objects are the same though.
Hence equals() will return true.
regards,
Jyotsna