Here is the basic Entry class you can use for the elements of the table:
public class Entry<K, V> {
private K key;
private V value;
public Entry(K key, V value) {
this.key = key;
this.value = value;
}
public K getKey() {
return key;
}
public V getValue() {
return value;
}
}
This almost the same Entry class used with the heap, but in this case we do not need to have the
key extend Comparable. If you still have the other Entry class available and wish to
use it, you may.
Create the HashTable class. The table should be implemented as an array of Object. The constructor should be:
The first two methods you should create are:
Use linear probing (look at the next consecutive indexes in the table) if there is a collision.
HashTable<Integer,String> table = new HashTable<Integer,String>(20); table.put(2004512, "Dick Cheney") table.put(2006143, "George Bush") table.put(2006233, "Condoleezza Rice") table.put(2005832, "Robert Gates") table.get(2006143) table.get(2005832) table.get(2006224)If you have completed that, try looking at the API for HashTable. Can you understand its description?