Is there a way to define a HashMap
that has another HashMap
as the value without warning?
I mean if I use generics I would have to define:
HashMap<Integer, HashMap<Integer, HashMap<Integer, HashMap<Integer,HashMap etc>> map = new HashMap<>();
Is the correct/only way to do it via the followin?
HashMap<Integer, HashMap> map = new HashMap<Integer, HashMap>();
Update based on comments:
I am just reviewing generics and I was under the impression that it is not uncommon to have a hashmap as a value of another hashmap.
Update based on @JimGarrison comment:
Using a hash of hashes is a very common structure in other languages so I am surprised that I need to actually give some specific use case in order for my question to make sense. If I need to give a real example that this could be used, one would be to e.g. navigate through some hierarchical structure. So we could "mimic" a tree.