So far we have said nothing about the implementation of hash tables in Java. To be specific, we shall consider a hash table implementation of a certain interface called a LookupTable.
The idea of a lookup table is that each entry should store a pair of objects, one of which is the key and the other is a corresponding value. For example you could consider a dictionary to be a lookup table, where the key is a word and the value is the dictionary definition of that word. Again, if the lookup table records the membership of a club, the key might be the member's name and the value might be the member's address, membership number, status etc. Here is simple LookupTable interface.
public interface LookupTable {
public boolean isEmpty();
public int size();
public boolean contains(Object key);
public void add(Object key, Object value);
public void remove(Object key);
public Object lookup(Object key);
public interface Entry {
public Object key();
public Object value();
}
public Iterator iterator();
}
The meanings of most of the LookupTable methods are fairly
clear from their names.