0

I have tried this

ScreenDumpParser dump = new ScreenDumpParser();
    Map btn_bound = dump.parse();

    Iterator iterator = btn_bound.keySet().iterator();

    while (iterator.hasNext()) {
       String key = iterator.next().toString();
       List<Integer> value = btn_bound.get(key);

       System.out.println(key);
    }

but this line

List<Integer> value = btn_bound.get(key);

gives error:

Type mismatch: cannot convert from Object to List<Integer>

I need to print all the values along with the key in one single row.

ashish mishra
  • 1,401
  • 2
  • 10
  • 13

1 Answers1

0

If you want to add a value to your List you should use:

value.add( btn_bound.get(key));

and if the button is a list or something else you must add more then one value to your list with

value.addRange( btn_bound.get(key));

And if you want to get a value:

Object foo = value.get(btn_bound.get(key));
FoldFence
  • 2,674
  • 4
  • 33
  • 57
  • Casting is completely unnecessary here. And this `List value = new List(btn_bound.get(key));` is wrong (mind that OPs question is in Java). – Tom Jun 10 '16 at 09:14
  • When I wrote the answer the language tag was missing so i wrote for Java and C# but i edit – FoldFence Jun 10 '16 at 09:16
  • Yeah, I know that the tag was missing, so no worries :). When you write something for two languages, then clearly write which part belongs to which language. The `new List<..>(...)` part clearly not for Java (for example). – Tom Jun 10 '16 at 09:25