Java: Using Classes as a value in hashmap [duplicate]
问题 This question already has answers here : Casting to a Class which is determined at run-time (2 answers) Closed 6 years ago . I'm trying to use custom Class as a value in a Map<String, Class<?>> . Following are relevant parts of code: Following is declaration and initialization of Map in main() : public static Map<String, Class<?>> mapQuery2ResponseType = new HashMap<String, Class<?>>(); static { mapQuery2ResponseType.put("string1", CustomClass1.class); mapQuery2ResponseType.put("string2",