Say I have a HashMap of HashMaps defined like this:
hashMap = new HashMap<String, HashMap<String, Integer>>();
How would I abstract over this to make the definition more clear?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If I interpret your question correctly, you have a collection which maps objects together and want to know if there is a way to do it that reads better.
It’s best if we define a purpose for each of the elements, so as an example:
In this case, you can create the following class:
This simplifies your collection to:
You can then simplify it further if you want, but this gives you an idea of what steps to take. The most important thing is to use names that make sense.