值我有一個HashMap
HashMap<Integer, ArrayList<Bundle>> hashMap
我能夠把值在HashMap
。並且散列表被傳遞給下一個類。現在如何從HashMap
得到Bundle
的ArrayList
。任何我如何使用Iterator
Set
。但我仍然無法列出作爲數組列表的HashMap的值。這實際上是Message拾取器。我有多選模式使用回調listview。當我點擊一個短信列表,我需要得到一些細節,並將其存儲在hashmap
。有可能短信可以有多個recepinets。 key
將位置。我需要將HashMap
的所有值爲ArrayList
合併成一個單一的ArrayList
。說int我們有[0,[A,B]],[1,[C,D]]的第0個位置,我想創建一個新的ArrayList並將A,B,C,D存儲在其中。檢索的ArrayList這是在HashMap中
-4
A
回答
1
2
這裏有一個完整的例子:
public class Test {
private final String value;
public Test(String value) {
this.value = value;
}
public static void main(String[] args) {
HashMap<Integer, ArrayList<Test>> example = new HashMap<Integer, ArrayList<Test>>();
ArrayList<Test> test1 = new ArrayList<Test>();
test1.add(new Test("HELLO"));
ArrayList<Test> test2 = new ArrayList<Test>();
test2.add(new Test("HELLO2"));
example.put(1, test1);
example.put(2, test2);
// We get the second arraylist
// Where 2 is the Integer we added in example.put(2, test2);
ArrayList<Test> testExtracted = example.get(2);
System.out.println(testExtracted.get(0).value); // Prints HELLO2
}
}
相關問題
- 1. 在HashMap的ArrayList中搜索HashMap
- 2. 從java中hashmap的arraylist檢索值?
- 3. 從ArrayList中檢索並使用hashmap存儲到新的Arraylist中
- 4. Arraylist中的HashMap
- 5. Java - 檢查ArrayList是否存在嵌套在HashMap中的值
- 6. 檢索ArrayList中的HashMap鍵的所有值Java
- 7. 在java中檢索hashmap值
- 8. HashMap和在檢索
- 9. ArrayList中的Java HashMap
- 10. 檢索XSLT中的hashmap值
- 11. 使用HashMap中,而不是ArrayList的
- 12. 在HashMap中存儲ArrayList
- 13. 在Java:List,ArrayList和Map中,HashMap
- 14. ArrrayList在檢索鍵值的Hashmap中
- 15. 以ArrayList作爲對象檢索HashMap的鍵值
- 16. 檢索的ArrayList中的Java
- 17. 從hashmap中檢索值(.values())
- 18. 如何檢索HashMap中值
- 19. 從HashMap中檢索位置
- 20. 的ArrayList在HashMap中在Java中
- 21. 在ArrayList中的HashMap <字符串,字符串>檢索從鍵/值值
- 22. IBatis + Java:檢索HashMap
- 23. 從TreeMap檢索HashMap
- 24. 檢索ArrayList的值
- 25. ArrayList作爲Hashmap中的鍵
- 26. ArrayList中的Hashmap更換
- 27. 在ArrayList的hashmap上迭代
- 28. 在POJO中檢索firebase hashmap數據
- 29. 在hashmap衝突中檢索實際值
- 30. 爲什麼用HashMap中的鍵檢索這些值?
Uhwell,使用'獲得()'...爲什麼這個問題嗎? – fge
不能你看看HashMap文檔? – Blackbelt
使用'.get()'。這是個問題嗎? –