How do you define a class of constants in Java?

后端 未结 10 2047
终归单人心
终归单人心 2020-12-07 12:44

Suppose you need to define a class which all it does is hold constants.

public static final String SOME_CONST = \"SOME_VALUE\";

What is the

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 13:24

    Your clarification states: "I'm not going to use enums, I am not enumerating anything, just collecting some constants which are not related to each other in any way."

    If the constants aren't related to each other at all, why do you want to collect them together? Put each constant in the class which it's most closely related to.

提交回复
热议问题