Overriding interface's variable?

后端 未结 4 2023
抹茶落季
抹茶落季 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:07

    The variable you declared in that interface is not visible to the class that implemented it.

    If you declare a variable in an static and final, i.e. a constant, THEN it is visible to implementors.

提交回复
热议问题