I have two different enums and i want to be able to output whether a given
string is a part of a enum collection. this is my code:
public class Check {
public enum Filter{SIZE, DATE, NAME};
public enum Action{COPY, DELETE, REMOVE};
public boolean isInEnum(String value, Enum e){
// check if string value is a part of a given enum
return false;
}
public void main(){
String filter = "SIZE";
String action = "DELETE";
// check the strings
isInEnum(filter, Filter);
isInEnum(action, Action);
}
}
eclipse says that in the last two lines “Filter can’t be resolved to a variable” but
apart from that it seems that the Enum param in the function “isInEnum” is wrong.
Something is very wrong here can anyone help?
The simplest (and usually most efficient) way is as follows:
and then you call
isInEnum(filter, Filter.class).