public class HashTable<K,V> {
    private RW rw;
    private List2<K,V> [] a;
    private int n;
    public HashTable (int n) {
	rw = new RW();
	a  = new List2[n];
	this.n = n;
    }
// continued...
    public V lookup(K key) throws 
	          	   InterruptedException {
	rw.startRead();
	int i = Math.abs(key.hashCode() % n);
	V result = (a[i] == null) ? null :
				    a[i].lookup(key);
	rw.endRead();
	return result;
    }
    public void update(K key, V value) throws 
                            InterruptedException {
        rw.startWrite();
        int i = Math.abs(key.hashCode() % n);
        if (a[i] == null)
            a[i] = new List2<K,V> (key,value,null);
        else 
            a[i].update(key,value);
        rw.endWrite();
    }
    public static void main(String[] args) {
        HashTable<String,Integer> h;
        h = new HashTable<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(); };
    }
} // end of class HashTable
