Java Field.isEnumConstant()
Syntax
Field.isEnumConstant() has the following syntax.
public boolean isEnumConstant()
Example
In the following code shows how to use Field.isEnumConstant() method.
//from www. j a va2s .com
import java.lang.reflect.Field;
enum Spy {
BLACK, WHITE
}
public class Main {
public static void main(String... args)throws Exception {
Class<?> c = Class.forName("Spy");
Field[] flds = c.getDeclaredFields();
for (Field f : flds) {
System.out.println(f.isEnumConstant());
}
}
}
The code above generates the following result.