I have a function which returns Map of String to List i.e Map<String,List<Integer>>
here is my piece of code
Map<String,List<Integer>> myList=new TreeMap<String, List<Integer>>();
List<Integer> firstList=new ArrayList<Integer>();
firstList.add(1);
firstList.add(2);
firstList.add(3);
myList.put("1", firstList);
List<Integer> secodList=new ArrayList<Integer>();
secodList.add(3);
secodList.add(4);
secodList.add(5);
myList.put("2", secodList);
for (int i = 0; i < myList.get("1").size(); i++) {
for (int j = 0; j < myList.get("2").size(); j++) {
System.out.println(myList.get("1").get(i) +" "+myList.get("2").get(j));
}
}
For the time being i have iterated over the loop since i know there is only 2 entries . But myListMap is growable it might have 3 entries , or even 4 entries how do i dynamically construct the for loop .