I have an enum that looks a little bit like this:
public enum Numbers {
ONE(1), TWO(2), THREE(3);
public final int num;
public Numbers(int num) {
this.num = num;
}
}
I want to be able to convert from argument to enum, for instance from the int 1
to the enum ONE
. Is there any built-in mechanism in Java Enums to do this, or do I have to write my own logic for it?