Geeks Talk

Prepare for your Next Interview




Java related

This is a discussion on Java related within the Java forums, part of the Software Development category; Why do you need to override Hashcode? what happens if you don't?...


Go Back   Geeks Talk > Software Development > Java

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 05-17-2007
Junior Member
 
Join Date: May 2007
Location: california
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
annaannam is on a distinguished road
Java related

Why do you need to override Hashcode? what happens if you don't?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-25-2007
Junior Member
 
Join Date: May 2007
Location: Hyderabad
Posts: 10
Thanks: 0
Thanked 2 Times in 2 Posts
swapnamarri is on a distinguished road
Re: Java related

Hi

If two objects are equal, their hash code must also be equal. If you override the equals() method, you change the way two objects are equated and Object's implementation of hashCode() is no longer valid. Therefore, if you override the equals() method, you must also override the hashCode() method as well.
Reply With Quote
Reply

  Geeks Talk > Software Development > Java


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Inter-Related Parameters ARB55 LoadRunner 1 05-02-2007 06:04 AM
A typical problem related to SQL anand.kr.singh SQL 0 03-30-2007 03:34 PM
Questions related to Test plan whizen Testing Issues 4 03-13-2007 02:52 PM
AudioGrail is the swiss army knife for everthing that is related to audio files. JobHelper Geeks Lounge 0 01-22-2007 12:20 PM


All times are GMT -4. The time now is 02:04 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved