I declared enum as an input to the switch statement since it doesn't allow String
values.
public enum names{VALUE1, VALUE2}
I have a List
of values (VALUE1, VALUE2, VALUE3)
for(int i=0; i<list.size();i++)
{
names n=new names(list.get(i).trim());
switch(n) {
case VALUE1:
System.out.println("1");
break;
case VALUE2:
System.out.println("2");
break:
default:
System.out.println("Nothing to print");
}
}
While executing the above-mentioned code, I am getting No Enum constant Class.data.VALUE3.
error. Please help me resolve this error.