对象比较
public class Person implements Comparable<Person>{
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
private double height;
private String name;
public Person(){}
public Person(double height,String name){
this.name = name;
this.height = height;
}
@Override
public int compareTo(Person o) {
return Double.compare(height, o.height);
}
}
上面是创建
------------------------------------------------------------------------------------------------------------