How to access Abstract superclass instance variable

白昼怎懂夜的黑 提交于 2019-12-02 13:12:01

That's because 95 / 100 is an integer division which yields 0 as a result. Try with

0.95 * super.value

or

95.0 / 100 * super.value

Instead of:

 this.value = 95 / 100 * super.value;

you should have:

 this.value = 95d / 100d * super.value;

95/100 results in the int value of 0.

On my phone, so I can't do appropriate code blocks, but here it goes.

private int x;

public int getX() {
    return x;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!