reference : java generic 


public static <E> Comparator<List<E>> listComparator(final Comparator<E> comp) {
return new Comparator<List<E>>() {
public int compare(List<E> list1, List<E> list2) {
int n1 = list1.size();
int n2 = list2.size();
for (int i = 0 ; i < Math.min(n1, n2) ; i++) {
int k = comp.compare(list1.get(i), list2.get(i));
if (k != 0) {
return k;
}
}
return (n1 < n2) ? -1 : (n1 == n2) ? 0 : 1;
}
};
}

'java core' 카테고리의 다른 글

Finally 범위  (0) 2009.07.15
How to get object size in java.  (0) 2009.05.29
JMX reference  (0) 2009.04.29
Effective Java Reload  (0) 2009.04.29
Rounding(Scaling) x postion of decimal point  (0) 2009.04.29
Posted by '김용환'
,