[JAVA]JAVAの宿題・課題は俺に任せろ v1.004[JAVA]
■ このスレッドは過去ログ倉庫に格納されています
0656655
NGNGclass ListComparator implements Comparator {
int elementIndex; // 何番目の要素で比較するか
public ListComparator(int elementIndex) {
this.elementIndex = elementIndex;
}
public int compare(Object o1, Object o2) {
// throws ClassCastException, IndexOutOfBoundsException, NumberFormatException
int value1 = Integer.parseInt(((List)o1).get(elementIndex));
int value2 = Integer.parseInt(((List)o2).get(elementIndex));
if(value1 == value2) return 0;
return value1 < value2 ? -1: 1;
}
}
とでもすれば、Arrays.sort()使ってもSortedSetにつっこんでもいいだろ。
■ このスレッドは過去ログ倉庫に格納されています