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