If I add custom class objects to HashSet and don’t provide hashCode() methods on them, how does it impact the perfomance of hashing?
Thanks,
Ajay
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
if you don’t define your own
hashCodemethod, the method from the parent Class of your object gets called. If you have no parent defined thehashCodemethod from the Object class gets called. According to the java api documentation the method returns an integer depending on the address of the object – but how exactly this is accomplished depends on the jvm and the operating system.In summary – if you don’t specify any hashCode methods it’s like putting Objects in the hashTable.