public Class Test{
HashMap<String, HashMap<String, String>> GlobalMap = new HashMap();
private String X;
public static void main(String[] args){
Test t1 = new Test();
t1.read(someTreeObject);
}
@Override
public Void method1(someCtx) {
String A = "some value";
String B = "some other value";
Map Map1 = new HashMap();
Map1.put(A,B);
System.out.println("Local Map : "+Map1.entrySet);
GlobalMap.put(X, (HashMap<String, String>)GlobalMap.get(X).putAll(Map1)); //<<<Compile time error details with the indicator pointing at Map1 within this line: error: incompatible types: void cannot be converted to HashMap<String,String>
// GlobalMap.put(X, (HashMap<String, String>)GlobalMap.get(X).put(new HashMap(A,B))); //<<<<<<<<<This is another approach, when tried gives a compile time error with the indicator pointing at A within this line: error: incompatible types: String cannot be converted to int
System.out.println("Global Map Details : \n"+GlobalMap.entrySet()+"\n");
}
return super.SomeMethod(someCtx);
}
Method1はもともと抽象インターフェイスで使用できるオーバーライドされたメソッドです。 私は、メインのメソッドに送ることが期待されるものは何もないことを知っています。パラメータ化されたHashMaps:コンパイル時エラー:互換性のない型
なぜputAllとputメソッドが異なるエラーメッセージを生成するのですか? 私は本当にここで何が欠けていますか?
私はプログラミングとJavaを初めて使い、高度なHashMapsを構築することを実際に試みています。以前の経験でジェネリックなHashMap構造を使用しているときに、私はこのエラーに似た何かに遭遇しませんでした。
はい、[putAll](https://docs.oracle.com/javase/7/docs/api/java/util/HashMap.html#putAll(java.util.Map))はvoid –