I am trying to create a new Hashmap<Integer, Map<String, Product>> from a filled HashMap<String,Product> applying Java Streams and I am receiving all time **java.util.HashMap$Node cannot be cast to class java.util.Map** and I am not able to see the what is wrong.

There is probably a simpler and more logical way to do it but this is what I came up with

```

Map<String, Product> hashMapChild = new HashMap<>();

hashMapChild.put("PC000123", new Product("reference1", "product1", price1));
hashMapChild.put("PC000234", new Product("reference2", "product2", price2));

Map<Integer, Map<String, Product>> hashMapParent = hashMapChild.entrySet()
                .stream()
                .collect(HashMap<Integer, Map<String, Product>>::new,
                         (map, streamValue) -> map.put((int) Math.floor(Math.random()*100),(Map<String, Product>) streamValue),

                         (map, map2) -> {
                             System.out.println(map);
                             System.out.println(map2);
                         });

        hashMapParent.forEach((k, v) -> System.out.println(k + ":" + v));

```

On the other hand. How would be possible to get an auto increment index instead of a random value?

Many thanks in advance

The output could be something like that:

```
<1, <COMPGAM012, Product{reference='COMPGAM012', name='laptop', prize=750.56}>>
<2, <PC000124, Product{reference='PC000124', name='Desktop', prize=400.56}>>

```