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

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -