62,623
社区成员
发帖
与我相关
我的任务
分享
public class Employyee implements Comparable {
private double salary;
public int compare(Object obj) {
return this.salary - ((Employe)obj).salary;
}
}
public void getPaySame() {
List allEmployee = getAllEmployee();//读取出所有员工
java.util.Collections.sort(allEmployee);
for(int i = 1; i < allEmployee.size(); i++) {
Employee last = (Employee)allEmployee.get(i - 1);
Employee current = (Employee)allEmployee.get(i);
if(last.salary == current.salary)
System.out.println(last.name + "=" + current.name);
}
}