Skip to content

程序员灯塔

Menu
  • 首页
  • 亲友位置共享
Menu

java 自定义类重写compare方法 ,使用Collections.sort排序

Posted on 2017 年 7 月 27 日

public class Bean implements Comparable {

…

…

@Override
public int compareTo(Bean_oneExp o) {

if(this.timestamp != o.getTimestamp()){
return (int)(this.timestamp – o.getTimestamp());//按照timestamp 升序
}else{
return this.location – o.location;
}

}

Collections.sort(exp_lst); // list里放的Bean对象

近期文章

  • 亲友位置共享APP-最简单的方式,让家人知道彼此在哪
  • 亲友位置共享
  • 技术网站
  • Git学习记录(learngitbranching.js.org)
  • 阿里职场潜规则

近期评论

您尚未收到任何评论。

归档

  • 2026 年 1 月
  • 2025 年 12 月
  • 2024 年 9 月
  • 2022 年 12 月
  • 2021 年 8 月
  • 2021 年 6 月
  • 2021 年 3 月
  • 2021 年 2 月
  • 2020 年 11 月
  • 2020 年 5 月
  • 2020 年 3 月
  • 2019 年 11 月
  • 2019 年 10 月
  • 2019 年 9 月
  • 2019 年 7 月
  • 2019 年 6 月
  • 2019 年 5 月
  • 2019 年 3 月
  • 2018 年 9 月
  • 2018 年 8 月
  • 2018 年 7 月
  • 2018 年 4 月
  • 2018 年 2 月
  • 2018 年 1 月
  • 2017 年 12 月
  • 2017 年 11 月
  • 2017 年 10 月
  • 2017 年 8 月
  • 2017 年 7 月

分类目录

  • 未分类
©2026 程序员灯塔 | Design: Newspaperly WordPress Theme