I have created the following class to validate certain values with constants. Why i am getting the following error? As the class need not to be initiated to use static methods, but still why it is trying to initiate. I am using java 1.6 Is this a good practice to do ?
public final class Approver{
// Avoids initiating this class
private Approver() {
}
private static final List<String> APPROVED_LENGTH= new ArrayList<String>() {
{
addAll(KM_APPROVED_LIST);
addAll(LM_APPROVED_LIST);
}
};
private static final List<String> KM_APPROVED_LIST = new ArrayList<String>() {
{
add("L");
add("G");
// so on
}
};
private static final List<String> LM_APPROVED_LIST = new ArrayList<String>() {
{
add("P");
add("K");
// so on
}
};
public static boolean isApproved(String lenth) {
return APRROVED_LENGTH.contains(length);
}
From another class
if(Approver.isApproved("K"))
{......}
error
Caused by: java.lang.NoClassDefFoundError: Could not initialize class ...Approver.class