I have a nested map with key as Employee name and values as another map with key as company name and value as years of experience like below
Map<String, Map<String, Integer>> map = new HashMap<>();
Map<String, Integer> innerMap1 = new HashMap<>();
innerMap1.put("INfosys", 2);
innerMap1.put("Volvo", 2);
innerMap1.put("MH", 3);
innerMap1.put("Piterion", 1);
Map<String, Integer> innerMap2 = new HashMap<>();
innerMap2.put("Tata", 2);
innerMap2.put("Bosch", 1);
innerMap2.put("Amber", 1);
innerMap2.put("E2", 1);
map.put("Rahul", innerMap1);
map.put("Amrita", innerMap2);
Now my function should return a Map with the employee name as key and total experience as value. How can I do that using java streams (in a single stream)
public Map<String, Integer> getEmployeesWithExp(Map<String, Map<String, Integer>> map) {
map.entrySet().stream().
...
return null;
}