读书人

兑现list自动排库

发布时间: 2013-01-23 10:44:49 作者: rapoo

实现list自动排库
/** * 因为要按倒序排列,所以大于返回-1,等于返回0,小于返回1 */ public int compareTo(DataObject otherData) { if (this == otherData) return 0; if (otherData == null) return -1; if (this.value > otherData.value) { return -1; } else if (this.value == otherData.value) { return 0; } else { return 1; } }

?3:使用Collections.sort(List<DataObject >对像);// 按倒序从大到小排列

读书人网 >编程

热点推荐