import java.util.Scanner;
public class Main {
enum TestEnum {
One(1), Two(2), Three(3);
private int code;
TestEnum(int code) {
this.code = code;
}
}
public static void main(String[] args) {
int n = new Scanner(System.in).nextInt();
System.out.println("n in TestEnum? " + isPresent(n));
}
private static boolean isPresent(int n) {
for (TestEnum testEnum : TestEnum.values()) {
if (testEnum.code==n) return true;
}
return false;
}
}
Если есть желание - можно пробовать гнать выше, но там уж как повезет.