首页 > 编程语言 > 详细

java基础

时间:2020-01-02 23:58:30      阅读:140      评论:0      收藏:0      [点我收藏+]

1. arraylist soring

1) Collections.sort(al);

2) 

    public void stackSorting(String stk) {
// write your code here
ArrayList<Integer> aa = new ArrayList<Integer>();

aa.sort(new Comparator<Integer>(){
@Override
public int compare(int arg0, int arg1){
return aa.get(arg0).compareTo(aa.get(arg1));
}
});

}
}
class SortByAge implements Comparator {
public int compare(Object o1, Object o2) {
Student s1 = (Student) o1;
Student s2 = (Student) o2;
return s1.getAge().compareTo(s2.getAge());
// if (s1.getAge() > s2.getAge())
// return 1;
// return -1;
}
}

java基础

原文:https://www.cnblogs.com/connie313/p/12142680.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!