日期:2014-05-20 浏览次数:20758 次
public class staff implements Comparable { private String name; private int age; private String salary; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getSalary() { return salary; } public void setSalary(String salary) { this.salary = salary; } @Override public int compareTo(Object obj) { if (obj instanceof staff) { staff st = (staff) obj; return st.salary - this.salary; } return -1; } }
//private String salary; private double salary; //public String getSalary() { public double getSalary() { return salary; } //public void setSalary(String salary) { public void setSalary(double salary) { this.salary = salary; }