I have a requirement in which I need to have an nested hashmap. But the depth would be decided at run time.
E.g. If at runtime, user says 3,
then my hashmap should be like
HashMap<String, HashMAp<String, HashMap<String, String>>>
if he says 4 then
HashMap<String, HashMAp<String, HashMap<String, HashMap<String, String>>>>
Is there any way to implement this kind of functionality? Some other API or toolkit??
Oh, this is almost certainly a very bad idea.
You sound like you really want a tree or graph and don’t know how to write it, so you’re inventing this notation to try and make it work with HashMap.
Don’t.
You’ll be better off by figuring out how to write what you need properly.
There’s no library to do what you want for a very good reason – you shouldn’t.