首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

兑现list自动排库

2013-01-23 
实现list自动排库/*** 因为要按倒序排列,所以大于返回-1,等于返回0,小于返回1*/ public int compareTo(Dat

实现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 >对像);// 按倒序从大到小排列

热点排行