3 depth Hashmap

Hi folks, I'm in need to create a HashMap within a HashMap within a HashMap, but I'm finding it hard to implement. I'm new at Java so this is alittle bit beyond what I did on the practical side, so any help would be much appreciated. I read a ton of tutorials, but couldn't make it work, so an example with code would be great!

I need to compare an input word with the first hashmap and give a response, but the second input should only check within the second HashMap depth taking into account the first response and the third one should be like wise...

The idea is to have (keyword, values) like: (windows, "What is the version you use?"), so that the second answer would be within the windows hashMap (windows8, "32 or 64 bits?") and the third one would only go into the windows8 HashMap.

Is this the best way to implement this?

Any help would be much appreciated.
Rodric MacOliverResearcherAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can put certainly put maps inside other maps.

I find it's much easier to read if you declare little dummy classes like this:
      public static class FinalMap extends HashMap<String, String> {}

and then you can just use 'FinalMap' instead of HashMap<String, String> which gets confusing once you have more maps as the parameters.

Using this you can setup something like this:

public class TestMaps {
	public static class FinalMap extends HashMap<String, String> {}
	public static class WindowsMap extends HashMap<String, FinalMap> {}
	public static class VersionMap extends HashMap<String, WindowsMap> {}

	public static void main(String[] args) {
		FinalMap windows32bitMap = new FinalMap() ;
		WindowsMap windows8Map = new WindowsMap() ;
		VersionMap topMap = new VersionMap() ;

		windows32bitMap.put("question", "answer") ;
		windows8Map.put("32", windows32bitMap) ;
		topMap.put("windows8", windows8Map) ;

Open in new window

Does that meet your needs?


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.