Comparable
2019-06-26 20:32 更新
Comparable 从小到大排序(即:this,o)所需Comparable示例:
class A implements Comparable<A>{
public int n;
@Override
public int compareTo(A o) {
// TODO Auto-generated method stub
if (this.n > o.n) {
return 1;
} else if(this.n == o.n) {
return 0;
} else {
return -1;
}
}
}
以上内容是否对您有帮助:
更多建议: