我想實現一個包含hashmap<integer,ArrayList<integer>>
和Arraylist<integer>
校驗值速滑運動員的肌肉的HashMap和ArrayList
我想測試中ArrayList的每一個值,如果它等於到ArrayList HashMap中值
例如第一個程序在HashMap中的第一元件與第二元件的第二數組列表元素數組列表元素散列映射等
如果是相等的餘incremete計數器並將其存儲在包含該密鑰和計數器
新散列映射這是我做的
HashMap<Integer, Integer> sim = new HashMap<Integer, Integer>();
List<Integer> listOperateur = new ArrayList<Integer>();
for (Map.Entry<Integer, ArrayList<Integer>> e : hmm.entrySet()) {
//hmm and listOperateur Already established and filled
if (e.getValue().equals(listOperateur)) {
count++;
}
sim.put(e.getKey(), count);
}
}
1.你沒有問一個問題,所以目前尚不清楚,你想知道什麼。 2.您的代碼將一個空數組列表與HashMap中包含的值進行比較。這聽起來不像你想要達到的。 3. HashMap條目的順序沒有實際含義。因此,將「第一元素」與任何事物進行比較都是沒有意義的 – Malt
我不知道該怎麼做 如何用第一個hashmap元素測試第一個arraylist元素,用第二個元素測試第二個元素等 如果比較的元素是相同的,我會在計數器中加1,將計數器存儲在新的散列映射中 – fatoma
HashMaps中的條目無序。術語「第一元素」沒有意義。 – Malt