//父类
public class Employee {
private String name;
private double salary;
public Employee(String name, double salary) {
this.name = name;
this.salary = salary;
}
public double getAnnual() {
return 12 * salary;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
}
//子类
public class Manager extends Employee {
public double bonus;
public Manager(String name, double salary, double bonus) {
super(name, salary);
this.bonus = bonus;
}
public double getBonus() {
return bonus;
}
public void setBonus(double bonus) {
this.bonus = bonus;
}
public double getAnnuals() {
return (super.getAnnual() + bonus);
}
public double a() {
return getAnnuals();
}
double b = getAnnuals();
}
//
public class PloyParameter {
public static void main(String[] args) {
Manager milan = new Manager("milan", 5000, 200000);
System.out.println(milan.a());
System.out.println(milan.b);
}
}
为何milan.a.()和milan.b 两次输出的不一样呢 ?前者是260000.0后者是60000.0. 请朋友们解答疑惑一下