首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

collection器皿的小程序

2012-12-21 
collection容器的小程序Student.javapackage com.zylpublic class Student implements ComparableStuden

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());}   }

热点排行