Reputation: 8717
Have a bit of trouble working with enums, how do you pass a method to an enum? This is a basic overview of the code:
public enum myEnum{
UNDEFINED, Value1, Value2
}
checkEnum(myEnum passedValue){
//do check stuff here
}
No I want to pass "Value1" to checkEnum but if I just say:
checkEnum(Value1);
Eclipse won't let me, in what format does my variable have to be to pass it to my method checkEnum?
Upvotes: 1
Views: 512
Reputation: 1309
It needs to be qualified, checkEnum(myEnum.Value1);
should work.
Upvotes: 0
Reputation: 137282
It should be:
checkEnum(myEnum.Value1);
Also, the convention is to start Enums and Class names in upper case letter. e.g.
checkEnum(MyEnum.Value1);
Upvotes: 4