Created
August 20, 2017 18:35
-
-
Save Pozo/13e782aab6c0e99d3e677cd4d4da36d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void lazyMap() { | |
Map<String, List<Integer>> map = new HashMap<>(); | |
final ArrayList<Integer> integers = new ArrayList<>(); | |
integers.add(32); | |
map.put("aaa", integers); | |
final String key = "aaa"; | |
final int value = 2; | |
if (!map.containsKey(key)) { | |
ArrayList<Integer> listOfValues = new ArrayList<>(); | |
listOfValues.add(value); | |
map.put(key, listOfValues); | |
} else { | |
map.get(key).add(value); | |
} | |
System.out.println(map); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment