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

.equals ( ) and ==

 
Himabindu Devulapalli
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Java gurus.,
When should I use .equals() and == in Java.
Is .equals() used for String objects alone ?
Thanks in adv...
--Bindu
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
== does shallow comparison. Whereas .equals() does deep comparison only if you override this method. As the .equals() of Object class does the same thing as == does, need to override this method.
boolean equals(Object´┐Żobj) Indicates whether some other object is "equal to" this one.
Hope this helps!
 
SaiRam NageshKumar
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just execute the following to clear ur doubt. If u're not cleared dig it again. Try with & without the commented(//) statement.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic