The Java Constants Interface Anti-Pattern

How do you define and use constants in Java? Most advice on Internet has the following opinions: Declare public static final for constants in a class Do not use Interfaces for constants The most common way to define a constant is in a class and using public static final. One can then use the constant in another class using ClassName.CONSTANT_NAME. Constants are usually defined in upper cases as a rule, atleast in Java. ...

November 8, 2020 · 5 min