When using Collection.sort in Java what should I return when one of the inner objects is null
Example:
Collections.sort(list, new Comparator<MyBean>() {
public int compare(MyBean o1, MyBean o2) {
return o2.getDate().compareTo(o1.getDate());
}
});
Lets say o2 is not null but o2.getDate() it is, so should I return 1 or -1 or 0 when adding a null validation?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…