public String getName()
{
return name;
}
public int getSum()
{
return sum;
}
//hashCode方法是有什么作用?
public int hashCode()
{
return name.hashCode()+sum*78;
}
public boolean equals(Object obj)
{
if (! (obj instanceof Students))
throw new ClassCastException("数据类型不匹配");
Students s = (Students)obj;
return this.name.equals(s.name) && this.sum==s.sum;
}
public String toString()
{
return "Student["+name+", "+ma+", "+cn+", "+en+"]";
}
@Override
public int compareTo(Students s) {
// TODO Auto-generated method stub
int num = new Integer(this.sum).compareTo(new Integer(s.sum));