This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes .equals ( ) and == Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark ".equals ( ) and == " Watch ".equals ( ) and == " New topic
Author

.equals ( ) and ==

Himabindu Devulapalli
Greenhorn

Joined: Apr 05, 2000
Posts: 18
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

Joined: Nov 22, 2008
Posts: 18944
== 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

Joined: Apr 06, 2000
Posts: 21
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
 
subject: .equals ( ) and ==
 
Similar Threads
java.lang.OutOfMemoryError
hash code equal method
equals() and hashcode()
equals and hashCode of Java7
-0.0 and +0.0