I have an enum of string, as in this example.
When my current element would be STRING_ONE, how can switch to the next Strings item in the enum with for instance the ++ operator?
Something like:
Strings myEnum = String.STRING_ONE;
myEnum++ ; // to have STRING_TWO for instance
?
EDIT: I do not want to iterate through all of those enum elements. These STRING_ONE, STRING_TWO etc are some sort of states. I want to implement a getNextState()
Method like
private void getNextstate(){
myCurrentstate++;
}
Now, I have this, which does not seem efficient
private void getNextstate(){
if(myCurrentstate == Strings.STRING_ONE) myCurrentstate == Strings.STRING_TWO;
else if(myCurrentstate == Strings.STRING_TWO) myCurrentstate == Strings.STRING_THREE;
//..
else if(myCurrentstate == Strings.STRING_NINTYNINE) myCurrentstate == Strings.STRING_HUNDRET;
}