读书人

collection器皿的小程序

发布时间: 2012-12-21 12:03:49 作者: rapoo

collection容器的小程序
Student.java

package com.zyl;public class Student implements Comparable<Student>{private Long studentId;private String name;public Student(){}public  Student(Long studentId,String name) {this.studentId=studentId;this.name = name;}public Long getStudentId(){return this.studentId;}public String getName() {return name=name;}    public int hashCode(){    return studentId.hashCode();    }        public boolean equals(Student stu){    if(stu==null) return false;    boolean isResult =    this.studentId.equals(stu.getStudentId())&&this.getName().equals(stu.getName());    return isResult;       }    public String toString(){             return "[studentId="+studentId+",name="+name+"]";      }    public int compareTo(Student student) {// TODO Auto-generated method stubreturn this.getStudentId().compareTo(student.getStudentId());}   }

读书人网 >编程

热点推荐