在Java中,如何通过外部集合从内部集合检索数据?
如果有收藏在Java中,如何通过外部集合从内部集合检索数据?,java,collections,Java,Collections,如果有收藏 ArrayList<Integer> al = new ArrayList<Integer>(); HashMap<String, ArrayList<Integer>> hm = new HashMap<String, ArrayList<Integer>>(); ArrayList al=new ArrayList(); HashMap hm=
ArrayList<Integer> al = new ArrayList<Integer>();
HashMap<String, ArrayList<Integer>> hm =
new HashMap<String, ArrayList<Integer>>();
ArrayList al=new ArrayList();
HashMap hm=
新的HashMap();
如何通过hm
从al
检索数据
例:我需要
hm
->2=-al
->4你可以这样说:
hm.get(string).get(integer);
如果你把它分开,它是这样的:
ArrayList<Integer> arlist = hm.get(string); // This will return the string's hash map value
int value = arlist.get(index); // This will return the ArrayList's index's element
ArrayList arlist=hm.get(字符串);//这将返回字符串的哈希映射值
int value=arlist.get(索引);//这将返回ArrayList的索引元素
有关HashMap的get()
的更多信息:
有关ArrayList的
get()
:的更多信息,请解释一下您的示例?