Java小功能
老板:下班前代码一定要发到线上哈!
程序员:好的。
第二天老板到公司了,问:“代码怎么还没有发布到线上啊?昨天不是说下班前吗?”
程序员:“是的,没错,是下班前,可是我还没下班呢”
↓↓
↓↓
↓↓
正文
1.List排序个根据某个字段:
List<SpkReceivetime> spkReceivetimeList = new ArrayList<>();
//List排序个根据某个字段
Collections.sort(spkReceivetimeList, new Comparator<SpkReceivetime>() {
public int compare(SpkReceivetime arg0, SpkReceivetime arg1) {
int hits0 = arg0.getSid();
int hits1 = arg1.getSid();
if (hits1 > hits0) {
return 1;
} else if (hits1 == hits0) {
return 0;
} else {
return -1;
}
}
});