Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何从`Map中提取整数数组的长度?
Map <Integer, ArrayList<Integer>> res = function() ; for (Map.Entry entry : res.entrySet()) { System.out.println(entry.getValue()); }
做System.out.println(entry.getValue().size());是不行的。
System.out.println(entry.getValue().size());
您需要为您的Entry.
Entry
for(Map.Entry<Integer, ArrayList<Integer>> entry : res.entrySet()){
否则,类型用法为raw。
看
当您检索 MAP 尝试以下行时,您缺少通用的东西
for(Map.Entry<Integer, ArrayList<Integer>> entry : res.entrySet())