java自学提问: cannot be resolved to a variable
自学到关于抽象类的内容这,照着视频里的代码敲出了以下这些,除了最后main函数里的那句。本来就是想自己随意检验一下。但是内容里newPro(zhang,33,8000)....
自学到关于抽象类的内容这,照着视频里的代码敲出了以下这些,除了最后main函数里的那句。本来就是想自己随意检验一下。但是内容里 new Pro(zhang,33,8000).work(); 这句,"zhang"那里总是报错,cannot be resolved to a variable,想询问这是怎么回事?
abstract class Employee
{
private String name;
private String id;
private double pay;
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 bonus;
Manager(String name,String id,double pay,int bonus)
{
super(name,id,pay);
this.bonus=bonus;
}
public void work()
{
System.out.println("manager work");
}
}
class Pro extends Employee
{
Pro(String name,String id,double pay)
{
super(name,id,pay);
}
public void work()
{
System.out.println("pro work");
}
}
public class AbstractTest
{
public static void main(String[] args)
{
new Pro(zhang,33,8000).work();
}
} 展开
abstract class Employee
{
private String name;
private String id;
private double pay;
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 bonus;
Manager(String name,String id,double pay,int bonus)
{
super(name,id,pay);
this.bonus=bonus;
}
public void work()
{
System.out.println("manager work");
}
}
class Pro extends Employee
{
Pro(String name,String id,double pay)
{
super(name,id,pay);
}
public void work()
{
System.out.println("pro work");
}
}
public class AbstractTest
{
public static void main(String[] args)
{
new Pro(zhang,33,8000).work();
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询