内のオブジェクトにアクセスする方法を、私は私のgetExpo
メソッド内のキーを使用して値を取得するためにハッシュマップオブジェクトにアクセスする必要があります。は、私は、静的ブロック内のハッシュマップをintializedている静的ブロック
は、私のクラスは、あなたがhmap
変数クラスの静的メンバにする必要があり、ここで
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;
}
}
ありがとう、私は仕事を得ました – Jessie