public int compareTo(Book book) {
if (sortBybId) {
if (sortASC)
return this.bId > book.bId ? 1 : this.bId == book.bId ? 0 : -1;
else
return this.bId > book.bId ? -1 : this.bId == book.bId ? 0 : 1;
} else if (sortBybName) {
if (sortASC) {
int result = this.bName.compareTo(book.bName); //111
return result;
} else {
int result = this.bName.compareTo(book.bName); //222
return result > 0 ? -1 : result == 0 ? result : 1;
}
} else if (sortBybDate) {
if (sortASC) {
int result = this.bDate.compareTo(book.bDate);
return result;
} else {
int result = this.bDate.compareTo(book.bDate);
return result > 0 ? -1 : result == 0 ? result : 1;
}
}
return 1; //默认返回值;
}
小弟想问一下 标识的//111 和 //222 两句代码是一样的 但是他们的实现怎么会不一样(一个实现的是升序 一个实现的是降序)
谢谢