public class TestEmployee{
public static void main(String[] args){
SalaryEmployee e1=new SalaryEmployee("zhao jun",2000.0,4);
System.out.println(e1.getSalary(4)); 
}
}
class Employee{
private String name;
private int month;
public Employee(String name,int month){
this.name=name;
this.month=month;
}
public double getSalary(int month){
return 0.0;
}
public int getMonth(){
return this.month;
}
}
class SalaryEmployee{
private double salary;
public SalaryEmployee(String name,double salary,int month){
super(name,month);
this.salary=salary;
}
public double getSalary(int month){

if(super.getMonth()==month){
return salary+100.0;
}
else return salary;
}
}
如上代码,编译时即出现错误,请高手指点!

解决方案 »

  1.   

    SalaryEmployee是继承Employee的,但你没有写啊,应该是:
    class SalaryEmployee extends Employee {.......
    ....
      

  2.   

    class SalaryEmployee  后面加 extends Employee 错误就不显示了
      

  3.   

    class SalaryEmployee extends Employee { }
    SalaryEmployee类应该继承Employee类。
    LZ漏写了 extends 关键字。
      

  4.   

    没有写继承,应当是class SalaryEmployee extends Employee
      

  5.   

    if(super.getMonth()==month){ 
    return salary+100.0; 
    是这里有错 super关键字是用在继承上的,朋友可能是初学吧,这些不太明白也是正常的,多看看网上的视频吧比看书来的容易!!!
      

  6.   

    楼主你加了extends还是会报错 因为你父类少个无参构造 子类无法初始化父类
    起码在Employee里还要加个public Employee(){}
      

  7.   

    class SalaryEmployee extends Employee { }