XXXXXVO[] general = XXXX.getXXXX();
Comparator comparator = new Comparator() {
DateFormat f = new SimpleDateFormat("dd/MM/yyyy");
public int compare(Object obj1, Object obj2) {
XXXXX gen11 = (XXXXXVO) obj1;
XXXXX gen22 = (XXXXXVO) obj2;
String firstString = gen11.getXXXXX().toString();
String secondString = gen22.getXXXX().toString();
if (secondString == null || firstString == null) {
return 0;
}
return f.parse(firstString).compareTo(f.parse(secondString));
}
};
Arrays.sort(general, comparator);
上面是按升序对数组进行排序的代码。我想按降序排列。如何在 JDK 1.4 中扭转这一点?