Could not find or load main class EmployeeTest
package imooc.com.work;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class EmployeeTest {
public static void main(String[] args) {
Employee one=new Employee("S",100000,121941);
Employee two=new Employee("G",123123,2131232);
Employee three=new Employee("C",100000,121942);
List<Employee> list=new ArrayList<Employee>();
list.add(one);
list.add(two);
list.add(three);
for(Employee n:list) {
System.out.println(n);
}
Collections.sort(list);
for(Employee E:list) {
System.out.println(E);
}
}
}
package imooc.com.work;
public class Employee implements Comparable <Employee> {
private String name;
private int number;
private int salary;
public Employee(String name,int number,int salary ) {
this.name=name;
this.number=number;
this.salary=salary;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
public String toString() {
return ("工资"+salary+"名字"+name+"编号"+salary);
}
public int compareTo(Employee o) {
int price1=this.getSalary();
int price2=o.getSalary();
int n=new Integer(price1-price2);
return n;
}
}
正在回答 回答被采纳积分+1
- 参与学习 人
- 提交作业 7317 份
- 解答问题 14452 个
想要入门学编程?多年一直活跃在编程语言排行版前列的Java是一个很好的选择。本路径将从Java基础语法、面向对象、常用工具类三部分,为你开启软件开发的大门!
了解课程


恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星