vendredi 13 novembre 2015

How do I find out the enum used in an EnumMap?

I have a test class with an internal enum and an EnumMap like the following. How do I find out which enum is used within the EnumMap?

enum MyEnum { ENUM1, ENUM2 }
EnumMap<MyEnum, String> emap = new EnumMap<>( MyEnum.class );
public void discover() {
  Class<?> eclass = ???;
  System.out.println( eclass );
}

should print

MyEnum.class





Aucun commentaire:

Enregistrer un commentaire