abstract class Employee
{
private String name;
private String id;
private double pay;
Employee() //在父类中写一个空参数的Employee()方法。
{
}
Employee(String name,String id,double pay)
{
this.name=name;
this.id=id;
this.pay=pay;
}
public abstract void work();
}
class Manager extends Employee
{
private int jiangJin;
Manager(String name,String id,double pay,int jiangJin)
{
super(name,id,pay);
this.jiangJin=jiangJin;
}
Manager()
{
}
public void work()
{
System.out.println("ok");
}
}
class Test
{
public static void main(String[] args)
{
//Manager m= new Manager("wt","13",23,1000); //提示找不到符号,怎么回事啊?
Manager m= new Manager();
m.work();
System.out.println("Hello World!");
}
}
你在父类中写一个空参数的,用子类去继承,然后才可以再子类中调用空参数的Manager()
看下代码吧。 |