I have a HashMap with integer and ArrayList of some Element objects. Element objects are described with price and amount. I want to go through all those elements in each ArrayList, sum them up by calling on each element element.price()
, and create a new HashMap which contains old keys from and new values representing summ of each arraylist. Keys for new hash map should remain the same. Trying to do this using streams.
public static HashMap<Integer, Double> findIncomes(HashMap<Integer, ArrayList<Element>> mapa){
Map<String, Double> m = mapa.entrySet().stream().flatMap()
return m;
}