jQuery in Action, 2nd edition
The moose likes Beginning Java and the fly likes equals() method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "equals() method" Watch "equals() method" New topic
Author

equals() method

Ramm Kummar
Greenhorn

Joined: Feb 10, 2009
Posts: 26
Does this statement is right?

"
The equals() method in class Object uses only the == operator for comparisons,
so unless you override equals(), two objects are considered equal only if the two
references refer to the same object.
"

So both equals and == returns the same if equals is not overidden.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14670
    
  11

This statement is an extract of the API. Check java.lang.Object.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).


[My Blog]
All roads lead to JavaRanch
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
nice picture of you here

http://en.wikipedia.org/wiki/Sachin_Tendulkar
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8434

Sachin Ramesh Tendulkar wrote:


Please check your private messages for an important administrative matter.


[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: equals() method
 
Similar Threads
hashCode() Method
Again String.
Need Help For Exam .
in what condition the equls to compare whether the two are the same object?
Compare two StringBuffer objects