0

How do i extract the length of integer array from a `Map?

Map <Integer, ArrayList<Integer>> res = function() ;

for (Map.Entry entry : res.entrySet()) {
  System.out.println(entry.getValue());        
}   

Doing System.out.println(entry.getValue().size()); does not work.

ERJAN
  • 23,696
  • 23
  • 72
  • 146

2 Answers2

5

You need to specify type arguments for your Entry.

for(Map.Entry<Integer, ArrayList<Integer>> entry : res.entrySet()){

Otherwise, the type usage is raw.

See

Community
  • 1
  • 1
Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
  • 100% thx, i felt like there was something obvious, but i did not know about this stuff - still lots of java to learn.! – ERJAN Mar 16 '14 at 15:58
1

You are missing generic thing when you are retrieving the MAP try below line

  for(Map.Entry<Integer, ArrayList<Integer>> entry : res.entrySet())
Rookie007
  • 1,229
  • 2
  • 18
  • 50