Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 500 Bytes

File metadata and controls

31 lines (21 loc) · 500 Bytes

HashMap

Initialization

Map<Integer, Integer> foo = new HashMap<>();

Insertion

Map<Integer, ArrayList> foo = new ArrayList<>(); 
foo.computeIfAbsent(2, t -> new ArrayList<>()).add(4);

Printing

// you cant use local variable inside it
foo.forEach((key, value) -> {
    System.out.println("key is" + key + " value is " + value);
});
      
for (Map.Entry<k, v> foo : map.entrySet()) {
    k key = foo.getKey();
    v value = foo.getValue();
}