无法从类Java创建对象

时间:2018-09-02 15:22:07

标签: java methods instance

我正在尝试从employee类创建一个新雇员。当我在员工类中添加“ void”时,我可以创建该对象,但它会弄乱子类。我觉得有一些简单的事情要解决。

employee employee1 = new employee();
employee1.employee(name[i][0], monthlySalary[i][0]);

public class employee {

public String name = "";
public int monthlySalary = 0;
public double annualSalary = 0;

public employee(String name, int monthlySalary){
this.name = name;
this.monthlySalary = monthlySalary;
this.annualSalary = annualSalary();
}
}

public class Salesman extends employee {

private int annualSales = 0;

public Salesman(String name, int monthlySalary, int annualSales) {
    super(name, monthlySalary);
    this.annualSales = annualSales;

}

0 个答案:

没有答案