Could not find or load main class EmployeeTest

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

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕珊 2019-02-11 13:40:40

你好!代码在我这里是可以正常运行的,运行效果如下:

http://img1.sycdn.imooc.com//climg/5c610a7a0001582102760192.jpg

打开EmployeeTest类,鼠标右键单击,选择Run As——Run Configurations...,在窗口中查看如下位置处是否是EmployeeTest。或者新建个工程,将代码拷贝到新建的工程下,再运行一下试试。

http://img1.sycdn.imooc.com//climg/5c610a36000148c407890381.jpg

祝学习愉快!

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师