iamukt iamukt - 4 months ago 37
Java Question

Separate Interface or Utility class for defining constants in core java project

I am working on a project (using JDK7) which has 30 to 40 constants. These constants are being used by many classes of my project. I want to separate these constants into a single file. Which type of file should I prefer?, Interface or Utility class, I am thinking of using interface. Would it be appropriate ?


According to the SonarQube rules Constants should not be defined in interfaces

Example from Eclipse with sonar binding

You should use a class or an enum.