代码
List<HTjfxFltjNew> hTjfxFltjNews = new ArrayList<>();
Collections.sort(hTjfxFltjNews, new Comparator<HTjfxFltjNew>() {
@Override
public int compare(HTjfxFltjNew o1, HTjfxFltjNew o2) {
return Integer.parseInt(o2.getCjzs())-Integer.parseInt(o1.getCjzs());//降序,升序反过来
}
});
hTjfxFltjNews为对象 Cjzs为字段
上述代码中,在集合内将按照 hTjfxFltjNews类中的Cjzs字段进行降序排序
本文介绍了如何使用Java的Collections.sort()方法对List<HTjfxFltjNew>类型的对象进行排序,特别关注了按照Cjzs字段进行降序排列的过程。
5070

被折叠的 条评论
为什么被折叠?



