SortedSet中的natural sort和custom comparator sort
发布时间
阅读量:
阅读量
1、自然排序和比较器排序
a、首先创建一个Student类的实体,随后需对toString()方法、hashCode()方法以及equals()方法进行重写操作。
1、在Student类中,通过右键菜单选择---------》source------》Generate toString()...的方式,即可生成toString()方法。
2、在Student类中,通过右键菜单选择---------》source------》Generate hashCode() and equals()...的选项,便可生成hashCode()方法和equals()方法。
package com.Reviewbj;
public class Student implements Comparable<Student>{
private int id;
private String name;
private int age;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
publi
全部评论 (0)
还没有任何评论哟~
