重写父类方法,怎么传入参数值
抽象类中的方法
1 | public abstract double area(); |
子类重写的方法
1 2 3 4 | public double area(){ double temp = Math.PI * this .radius* this .radius; return temp; } |
若重写方法带有参数列表,则不能实现重写,例如
1 2 3 4 5 | public double area( double radius){ setRadius(radius); double temp = Math.PI * this .radius* this .radius; return temp; } |
请问,在什么情况下,重写父类的方法,可以在调用时传入参数列表
7
收起
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧