Is the any difference in performance and/or any other benefits we can get when using final keyword with constant utility class. [ This class contains only static final fields and private constructor to avoid object creation]
public class ActionConstants {
private ActionConstants() // Prevents instantiation
{ }
public static final String VALIDFIRSTLASTNAME = "[A-Za-z0-9.\\s]+";
public static final String VALIDPHONENUMBER = "\\d{10}";
...
...
}
Only diffrence is class is made final
public final class ActionConstants {
private ActionConstants() // Prevents instantiation
{ }
public static final String VALIDFIRSTLASTNAME = "[A-Za-z0-9.\\s]+";
public static final String VALIDPHONENUMBER = "\\d{10}";
...
...
}
I like to know, is there any benefits there in using final and what is the correct way to define class for constants.