I'm still not good with functional programming and therefore need help. Could you please help me write the same thing using stream API.
Thanks in advance.
Map<Integer, Map<Integer, ArrayList<Integer>>> map = new TreeMap<>();
ArrayList<ArrayList<Integer>> result = new ArrayList<>();
for(Map.Entry<Integer, Map<Integer, ArrayList<Integer>>> ele: map.entrySet()){
    ArrayList<Integer> temp = new ArrayList<>();
    for(Map.Entry<Integer, ArrayList<Integer>> ent: ele.getValue().entrySet()){
        temp.addAll(ent.getValue());
    }
    result.add(temp);
}
This is my approach. But there are some errors.
System.out.println(
    map.values()
        .stream()
        .map(ins -> { 
            ArrayList<Integer> temp = new ArrayList<>();
            ins.values().stream().forEach(temp::addAll);
            return temp;
        })
        .collect(Collectors.toList()));