File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

double equal sign vs equals() method

 
Nick Petas
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I compare two objects which of the two ways I must choose?
Thank you very much!
 
Campbell Ritchie
Sheriff
Pie
Posts: 47228
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
== 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: 1 2 3 4. And there will be many others.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic