void (String[] args) { List<Test> data = new ArrayList<>(); Map<String, Map<String, Integer>> result = data.stream().collect( Collectors.groupingBy( Test::getName, Collectors.groupingBy( Test::getMonth, Collectors.summingInt(Test::getAmount)) ) ); }