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 Beginning Java and the fly likes how to override equals() method in java?? 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 » Java » Beginning Java
Bookmark "how to override equals() method in java??" Watch "how to override equals() method in java??" New topic
Author

how to override equals() method in java??

gopal kishan
Ranch Hand

Joined: Feb 23, 2005
Posts: 99
Hi All,

how to override equals() method in java?? is it possible??

and can you tell me what is hashCode() where it works, and how??


thanks in advance
Gopal
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
All you need to know about hashcode and equals, but were afraid to ask


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Hentay Duke
Ranch Hand

Joined: Oct 27, 2004
Posts: 198
how to override equals() method in java?? is it possible??


Yes it is possible

and can you tell me what is hashCode() where it works, and how??


Better for you to google for it and try it out yourself.
Jagan Nambi
Greenhorn

Joined: Jan 16, 2004
Posts: 15
Yes, you can override equals().

In Java, java.lang.Object is at the top of the class hierarchy. The equals() method is declared in java.lang.Object as public boolean equals(Object obj). In your class, declare this method and write your code within this method. That basically constitutes overriding the equals() method.

Hope this helps!
gopal kishan
Ranch Hand

Joined: Feb 23, 2005
Posts: 99
HI All,

Thanks for your reply.


regards
Gopal
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to override equals() method in java??
 
Similar Threads
compare object
how to override Java's own methods?
String related
need help plss
equals() problem