1. Java encapsulation class
Student. java:
/*** @ Title: Student. java * @ Package: com. you. data * @ Description: * @ Author: youhaidong * @ date: 10:33:20, January 1, March 17, 2014 * @ Version V1.2.3 */package com. you. data; import java. util. comparator;/*** @ class Name: Student * @ Description: * @ Author: Administrator * @ date: 10:33:20, January 1, March 17, 2014 */public class Student implements Comparator
{/*** ID */private Long id;/*** student ID */private int stuNo;/*** name */private String stuName; /*** age */private int age;/*** Gender */private String sex;/*** @ Description: get Method * @ date: march 17, 2014 10:36:11 * @ return the id */public Long getId () {return id;}/*** @ Description: set Method * @ date: march 17, 2014 10:36:11 * @ param id the id to set */public void setId (Long id) {this. id = id;}/*** @ Description: get Method * @ date: 10:36:11, January 1, March 17, 2014 * @ return the stuNo */public int getStuNo () {return stuNo ;} /*** @ Description: set Method * @ date: March 17, 2014 10:36:11 * @ param stuNo the stuNo to set */public void setStuNo (int stuNo) {this. stuNo = stuNo;}/*** @ Description: get Method * @ date: 10:36:11, January 1, March 17, 2014 * @ return the stuName */public String getStuName () {return stuName ;} /*** @ Description: set Method * @ date: March 17, 2014 10:36:11 * @ param stuName the stuName to set */public void setStuName (String stuName) {this. stuName = stuName;}/*** @ Description: get Method * @ date: 10:36:11, January 1, March 17, 2014 * @ return the age */public int getAge () {return age ;} /*** @ Description: set Method * @ date: March 17, 2014 10:36:11 * @ param age the age to set */public void setAge (int age) {this. age = age;}/*** @ Description: get Method * @ date: 10:36:11, January 1, March 17, 2014 * @ return the sex */public String getSex () {return sex ;} /*** @ Description: set Method * @ date: March 17, 2014 10:36:11 * @ param sex the sex to set */public void setSex (String sex) {this. sex = sex;}/*** (non-Javadoc )*
Title: compare
*
Description:
* @ Param o1 * @ param o2 * @ return * @ see java. util. comparator # compare (java. lang. object, java. lang. object) * March 17, 2014 10:33:20 */@ Overridepublic 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 ;}}