R
R
reus2017-04-05 18:01:39
Java
reus, 2017-04-05 18:01:39

How to work with nested ArrayList in HashMap?

For example I have:

HashMap<Integer, ArrayList<String>> containerA = new HashMap<Integer, ArrayList<String>>();
Integer ea = 11;

How to add an element to an ArrayList by key? If, for example, you do this: then if there is no such key, then there will be an error.
containerA.put(ea, add("LOL"));//будет ошибка
containerA.get(ea).add("LOL");

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question