java - Creating a Hashtable - Equals method -
i'm studying course in data structures & algorithms, , have got assignment our teacher create hashtable chaining collision resolution technique.
for each entry in hash table our teacher wants have equals method:
@override public boolean equals(object obj) { entry keytocompare = new entry(obj, null); return key.equals(keytocompare.key); }
what difference when writing compared if compare keys regular .equals?
here complete class:
public class entry<t> { private object key; private object value; public entry(t key, t value){ this.key = key; this.value = value; } public boolean equals(object obj){ //what think should work return key.equals(obj); } }
Comments
Post a Comment