public class HashTableImproved<K,V> {
    private RW rw;
    private ListHead<K,V> [] a;
    private int n;
    public HashTableImproved (int n) {
	rw = new RW();
	a  = new ListHead[n];
        for (int i=0; i<n; i++)
            a[i] = new ListHead<K,V>();
	this.n = n;
    }
// in der Klasse HashTable:
public V lookup (K key) throws InterruptedException {
    int i = Math.abs(key.hashCode() % n);
    return a[i].lookup(key);
}
public void update (K key, V value) 
		   throws InterruptedException {
    int i = Math.abs(key.hashCode() % n);
    a[i].update (key, value);
}
    public static void main(String[] args) {
        HashTableImproved<String,Integer> h;
        h = new HashTableImproved<String,Integer>(10);
        try {h.update("Banane",5);
            System.out.println("search Banane: " +h.lookup("Banane"));
            System.out.println("search Orange: " +h.lookup("Orange"));
        }
        catch (InterruptedException e) { e.printStackTrace(); };
    }
}    
