If I have two enums, say:
public enum E1 {
A, B
}
public enum E2 {
A, B
}
Is there any way I can assign a value of the enum type E2 to the value of type E1, like this:
E2 var = E1.B;
(Assuming that I know in advance that B exists in both enums)
Edit:
I understand that Java doesn't allow this. Maybe I should explain this as well then. I have a variable (x) of type enum E1 (it can be A or B). For the task that I'm trying to achieve, I need to have another variable of type enum E2 with the same value. The way that I'm handling this right now is basically:
if (x == E1.A) {
E2 var = E2.A;
} else {
E2 var = E2.B;
}
So I guess what I'm asking this is that is there any nicer way to do this?
E1,E2andAandBreally are, you might get better answers.