Why do we declare Loggers static final?

后端 未结 14 2063
陌清茗
陌清茗 2020-11-28 01:19

In Java, why is it best practice to declare a logger static final?

private static final Logger S_LOGGER
14条回答
  •  误落风尘
    2020-11-28 01:57

    When would you want to change the value of the field?

    If you're never going to change the value, making the field final makes it obvious that you'll never change the value.

提交回复
热议问题