File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets 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: 3064
    
  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
 
 
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()