Method parameter mismatch: Required double, no argument passed

前端 未结 2 716
长发绾君心
长发绾君心 2021-01-29 12:53

I am almost complete but when I compile I get the error \"Method getUserTax in class IncomeTax cannot be applied to given types; required double; found: no arguments; reason: ac

2条回答
  •  逝去的感伤
    2021-01-29 13:26

    Just change this method signature: -

    public static double getUserTax(double income)
    

    to: -

    public static double getUserTax()
    

    You don't need to pass any income parameter, as that you are already having income as instance attribute in IncomeTax class. And when you invoke this method on an IncomeTax instance: -

    test.getUserTax();
    

    the income used in the method is nothing but this.income, which references the instance attribute.

提交回复
热议问题