interface Comparator { public int compare(A x, A y); } class ByteComparator implements Comparator { public int compare(Byte x, Byte y){ return x.byteValue() - y.byteValue(); } } class Collections { public static A max(Collection xs, Comparator c){ Iterator xi = xs.iterator(); A w = xi.next(); while(xi.hasNext()){ A x = xi.next(); if(c.compare(w,x) < 0) w = x; } return w; } }