Предположим, вам нужно определить класс, который всего лишь хранит константы.
Код: Выделить всё
public static final String SOME_CONST = "SOME_VALUE";
- Interface
- Abstract Class
- Final Class
Clarifications to some answers:
Enums - 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.
Interface - I'm not going to set any class as one that implements the interface. Just want to use the interface to call constants like so:
Код: Выделить всё
ISomeInterface.SOME_CONSTИсточник: https://stackoverflow.com/questions/479 ... ts-in-java
Мобильная версия