我已经在静态块中初始化了哈希映射,我需要访问哈希映射对象以在我的getExpo
方法中使用它的键来获取值。
我的课在这里
public class ExampleFactory {
static
{
HashMap<String,Class<?>> hmap = new HashMap<String,Class<?>>();
hmap.put("app", application.class);
hmap.put("expo", expession.class);
}
public void getExpo(String key,String expression)
{
// I need to access the object in static block
Class aclass=hmap.get(key); // it works when i place it inside main method but
// not working when i place the create object for
// Hashmap in static block
return null;
}
}