I have an enum, and I want to convert the class into Class without reflection.
For example, the enum is Numbers.java
public enum Numbers {
ONE, TWO, THREE;
}
The best I can do is using reflection, as follow
Class<Enum> enumClass = (Class<Enum>) Class.forName("com.package.inner.eveninner.Numbers");
Is there any way to do it without using reflection?
Class<Enum> enumClass = (Class<Enum>) Numbers.class;
gives an compile error:
incompatible types: Class<Numbers> cannot be converted into Class<Enum>
Aucun commentaire:
Enregistrer un commentaire