Rohan Deshmkh wrote:This is what i think:
1) == checks if both types being checked for == refers to a same object or not?It doesn't care about the values.
Yes and no. It's true that equals doesn't care about the state (contents) of any object. However, the == operator
always compares the values of its operands. However, the operands are never objects. They are either primitives or references. In the case of references, comparing those references' values amounts to "checking if they point to the same object, or are both null".
2)equals() method cares only about the value and does not care about if the types that are checked for equals , refers to same object or not.
The equals method does whatever it is coded to do. If it's written correctly--that is, if it follows the contract laid out in it documentation--it will return true of the two objects being compared are "equal" according to that class's semantics. What "equal" means depends on the class in question. It's up to the class author to decide.
[EDIT: Oops, guess I just repeated what DB said for #2. Oh well.

]