public class Map的嵌套 {
public static void main(String[] args) {
/**
* 结构 :
* -------------------------
* | V
* K |-----------------
* | K V
* -------|-----------------
* | { 1 "..." }
* 1 | { 2 "..." }
* | { 3 "..." }
* ------|-----------------
* | { 1 "..." }
* 2 | { 2 "..." }
* | { 3 "..." }
* ------|-----------------
* | { 3 "..." }
* 3 | { 2 "..." }
* | { 3 "..." }
* ---------------------------
*/
HashMap<String, HashMap<String, String>> 总框架 = new HashMap<String, HashMap<String, String>>();
HashMap<String, String> values框架1 = new HashMap<String, String>();
values框架1.put("v101", "values1_1");
values框架1.put("v102", "values1_2");
HashMap<String, String> values框架2 = new HashMap<String, String>();
values框架2.put("v201", "values2_1");
values框架2.put("v202", "values2_2");
总框架 .put("01", values框架1);
总框架 .put("02", values框架2);
for (String 总Key : 总框架 .keySet()) {
HashMap<String, String> 总values = 总框架.get(总Key);
for (String 对应的总values : 总values.keySet()) {
String 具体values = 总values.get(对应的总values);
System.out.println( 总Key + " " + 对应的总values +" "+具体values);
}
}
}
}
|