Overriding interface's variable?

后端 未结 4 2041
抹茶落季
抹茶落季 2020-12-10 04:29

As I read from various Java book and tutorials, variables declared in a interface are constants and can\'t be overridden.

I made a simple code to test it

<         


        
4条回答
  •  甜味超标
    2020-12-10 05:11

    You did not override the variable, you shadowed it with a brand-new instance variable declared in a more specific scope. This is the variable printed in your printx method.

提交回复
热议问题