Why we should not use protected static in java

前端 未结 8 2007
醉梦人生
醉梦人生 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

    There is nothing wrong with having protected static. One thing a lot of people are overlooking is that you may want to write test cases for static methods that you don't want to expose under normal circumstances. I've noticed this is particularly useful for writing tests for static method in utility classes.

提交回复
热议问题