Java之List排序
2014-03-17 22:55
357 查看
1、Java封装类
Student.java:
Student.java:
/** * @Title:Student.java * @Package:com.you.data * @Description: * @Author: 游海东 * @date: 2014年3月17日 下午10:33:20 * @Version V1.2.3 */ package com.you.data; import java.util.Comparator; /** * @类名:Student * @描述: * @Author:Administrator * @date: 2014年3月17日 下午10:33:20 */ public class Student implements Comparator<Student> { /** * ID */ private Long id; /** * 学号 */ private int stuNo; /** * 姓名 */ private String stuName; /** * 年龄 */ private int age; /** * 性别 */ private String sex; /** * @Description:get方法 * @date:2014年3月17日 下午10:36:11 * @return the id */ public Long getId() { return id; } /** * @Description:set方法 * @date:2014年3月17日 下午10:36:11 * @param id the id to set */ public void setId(Long id) { this.id = id; } /** * @Description:get方法 * @date:2014年3月17日 下午10:36:11 * @return the stuNo */ public int getStuNo() { return stuNo; } /** * @Description:set方法 * @date:2014年3月17日 下午10:36:11 * @param stuNo the stuNo to set */ public void setStuNo(int stuNo) { this.stuNo = stuNo; } /** * @Description:get方法 * @date:2014年3月17日 下午10:36:11 * @return the stuName */ public String getStuName() { return stuName; } /** * @Description:set方法 * @date:2014年3月17日 下午10:36:11 * @param stuName the stuName to set */ public void setStuName(String stuName) { this.stuName = stuName; } /** * @Description:get方法 * @date:2014年3月17日 下午10:36:11 * @return the age */ public int getAge() { return age; } /** * @Description:set方法 * @date:2014年3月17日 下午10:36:11 * @param age the age to set */ public void setAge(int age) { this.age = age; } /** * @Description:get方法 * @date:2014年3月17日 下午10:36:11 * @return the sex */ public String getSex() { return sex; } /** * @Description:set方法 * @date:2014年3月17日 下午10:36:11 * @param sex the sex to set */ public void setSex(String sex) { this.sex = sex; } /** * (非 Javadoc) * <p>Title: compare</p> * <p>Description: </p> * @param o1 * @param o2 * @return * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) * 2014年3月17日 下午10:33:20 */ @Override public int compare(Student o1, Student o2) { Student stu1 = (Student)o1; Student stu2 = (Student)o2; if(null != stu1 && null != stu2) { if(stu1.getStuNo() < stu2.getStuNo()) { return 1; } else { return 0; } } return -1; } }
相关文章推荐
- Java两个list合并后逆序排序
- JAVA中对list map根据map某个key值进行排序
- Java 数组排序 和 list排序 总结
- java对list集合使用comparator方法比较排序
- Java中List的排序
- Java集合排序及java集合类详解--(Collection, List, Set, Map)
- java List 排序 Collections.sort() 对 List 排序
- JAVA:List<T> 排序
- java collection.sort()根据时间排序list
- java中的List排序[转]
- java中集合排序,List<Map>,List<T>类型或者JSONObject的升序和降序排序
- java中对list排序问题
- java list按照元素对象的指定多个字段属性进行排序
- JAVA中Collections.sort()实现List排序的公共方法和自定义方法
- [编写高质量代码:改善java程序的151个建议]建议81 非稳定排序推荐使用list
- JAVA对LIST<Map<String,Object>>的排序
- Java对List集合中的元素进行排序
- 由Java中的Set,List,Map引出的排序技巧
- java List 排序 Collections.sort() 对 List 排序
- java中list<Object[]>、list<Student>、list<Map<String,String>>排序