I have desperate doubt on following:
let's say I create
hashset<employee> set = new hashSet();
employee e1 = new employee("adithyan",1);
employee e2 = new employee("santhosh",1);
employee e3 = new employee("pavan",2);
set.add(e1);
--- e1 is object how hashtable generates unique hashcode for this and how this object will be stored in hashtable as we know hashtable will store key and value pair
set.add(e2);
-- let's say e1 and e2 hashcode are same and value gets stored in same bucket and if I do search on id=1, how it will search because e1 and e2 hashcodes are same, probably e1 and e2 would be stored in same bucket, what would be the result for this?
I am confused with bucketing which has more than one objects along with objects has same data(let's say bucket1->object1.city=bglr,object2.city.=bglr)- in this case hashcode will be the same because both objects are in same bucket, I don't know how searching would work!
can somebody explain how hashset uses hastable with same hashcode and bucketing concept?