0
How do I get the value from an enum?
Say I write an enum called ExampleEnum. The constants I write in it are AND, OR, NOT How do i check if the value of a ExampleEnum object is one of those ? For instance I have: public boolean checkValue() which checks if the value of the enum is AND or OR and returns true for them, otherwise returns false. Does doing “if (this == ExampleEnum.NOT)” and so forth work? Or is there another keyword I’m supposed to be using?
1 Antwort
+ 2
I think it should work.
Here is an example with switch:
https://www.sololearn.com/learn/Java/2174/?ref=app
And here is my example:
https://code.sololearn.com/ccKce03uWJ7b/?ref=app