Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes equals() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
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: 14687
    
  16

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: 10376
    
    8

Sachin Ramesh Tendulkar wrote:


Please check your private messages for an important administrative matter.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: equals() method