Why we should not use protected static in java

前端 未结 8 2008
醉梦人生
醉梦人生 2020-11-29 17:01

I was going through this question Is there a way to override class variables in Java? The first comment with 36 upvotes was:

If you ever see a p

8条回答
  •  盖世英雄少女心
    2020-11-29 17:27

    Protected is used so that it can be used in subclasses. There is no logic in defining a protected static when using in the context of concrete classes as you can access the same variable is a static way.However the complier will give a warning to access the super class static variable in a static way.

提交回复
热议问题