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