When I compare two objects which of the two ways I must choose? Thank you very much!
posted 8 years ago
== tells you whether they are both the same object. equals() tells you that they satisfy whatever criteria that class has to be regarded as equal. If the API documentation for your class has "equals" under "methods inherited from Object" then it simply uses == to see whether both Objects are the same object. Look at a few other threads which might help: 1234. And there will be many others.