• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why equals method in Object class  RSS feed

 
Mustafa Garhi
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only advantage i can see of having the equals method in Object class is default implementation if you did not override it.

Is there anything else i cannot think of?

To put it the other way, why can't we have an independent equals method in our class than overriding the Object one?

Thanks in advance
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can write your own equals method. but java api like collection do not know about your own equals method. for that you need to reinvent the wheel of collection again.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!