我有一個HashMap
包含單詞Map<String,ArrayList<string>>
的列表,也包含話,我想比較這個名單與HashMap
這給了我們另一個HashMap
包含列表二進制值 1如果單詞存在0,如果不存在。 The problem is it adds the first list to the 2nd .... 代碼比較HashMap的<字符串,ArrayList的<String>>和ArrayList <String>的Java
HashMap<String,ArrayList<String>> hmm=new
HashMap<String,ArrayList<String>>();
System.out.println("affichage liste:");
for (Entry<String, List<String>> ee : hm.entrySet()) {
String key = ee.getKey();
List<String> values = ee.getValue();
for (String temp : list)
hmm.add(values.contains(temp) ? "1" : "0");
}
請將您的代碼以文本形式發佈,而不是圖片形式。 – px06
請參閱下面的答案。 –
我不明白比較'地圖<字符串,列表>'到'列表'背後的過程 - 他們自己顯然永遠不會彼此相等。那是地圖鍵?什麼是地圖值?列表中有什麼?什麼是成功的比較?什麼不是?請詳細說明你的問題,這對我來說目前沒有任何意義。 –