STYLE 1
public interface Constants{
String FOO = "foo",
BAR = "bar",
... ;
}
STYLE 2
public interface Constants{
String FOO = "foo";
String BAR = "bar";
...
}
I used to declare all the constants in a single interface. I am following style 1 because it's more readable. I am wondering if there's any difference between these two styles other than the readability. Is there any performance related things about these two styles?
NOTE : I never implemented the Constant
interface, instead I accessed those constants like
Constants.FOO
.
example :
public class Main{
public static void main(String[] args){
...
System.out.println(Constants.FOO);
...
}
}
Which is better, and why?