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 Java in General and the fly likes Can I Override equals() and hashCode() in my class 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 » Java in General
Bookmark "Can I Override equals() and hashCode() in my class" Watch "Can I Override equals() and hashCode() in my class" New topic
Author

Can I Override equals() and hashCode() in my class

Mahi Ranga
Ranch Hand

Joined: Jan 27, 2011
Posts: 35
Hi,

I have one doubt ,i.e Can I Override equals() and hashCode() in my class.If i override these two methods what will happen.

Thanks in Advace.

Regards,
Mahi.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

Yes you can override.
For what will happen on overriding you can have search for similar posts in this Forum ( SearchFirst )


Mohamed Sanaulla | My Blog
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can I Override equals() and hashCode() in my class
 
Similar Threads
equal() & hashcode() override (Kathy Sierra)
if we override hashCode method is compulsary to override equals method and viseversa.
enums
Problem with mock exam question
Overriding hashCode() and equals()