String[] codeA="黯 鏖 鳌 鏊 霭 螯 聱 鹌 锿 锕";
String[] codeB="鬓 鞴 魃 髌 髀 鳔 鳊 鲅 鐾 踣";
String[] codeC="黪 黜 魑 鲳 雠 龊 龀 躔 蹴 蹰";
String[] codeD="黩 黛 髑 骶 鞑 靼 鲽 鲷 貂 踱";Map<String, String[]> map = new HashMap<String, String[]>();
map.put("a", codeA);
map.put("b", codeB);
map.put("c", codeC);
map.put("d", codeD);
因为我把codeA,B,C,D都存放到map里去了,也就意味着codeA或者B他们缩对应的字的键为a,b
现在我想要把这些字的全部键位都输出出来,请问该怎么做呢???
String[] codeB="鬓 鞴 魃 髌 髀 鳔 鳊 鲅 鐾 踣";
String[] codeC="黪 黜 魑 鲳 雠 龊 龀 躔 蹴 蹰";
String[] codeD="黩 黛 髑 骶 鞑 靼 鲽 鲷 貂 踱";Map<String, String[]> map = new HashMap<String, String[]>();
map.put("a", codeA);
map.put("b", codeB);
map.put("c", codeC);
map.put("d", codeD);
因为我把codeA,B,C,D都存放到map里去了,也就意味着codeA或者B他们缩对应的字的键为a,b
现在我想要把这些字的全部键位都输出出来,请问该怎么做呢???
String[] codeA={"黯","鏖","鳌 ","鏊","霭","螯","聱","鹌","锿","锕"};
String[] codeB={"鬓","鞴","魃","髌","髀","鳔","鳊","鲅","鐾 ","踣"};
String[] codeC={"黪","黜","魑","鲳","雠 ","龊"," 龀"," 躔"," 蹴"," 蹰"};
String[] codeD={"黩","黛","髑 ","骶 ","鞑 ","靼"," 鲽 ","鲷 ","貂 ","踱"}; Map<String, String[]> map = new HashMap<String, String[]>();
map.put("a", codeA);
map.put("b", codeB);
map.put("c", codeC);
map.put("d", codeD);
Set<String> keyset = map.keySet();
Iterator<String> iterator = keyset.iterator();
while(iterator.hasNext()){
System.out.println(iterator.next());
}
}
String[] codeA={"黯","鏖","鳌 ","鏊","霭","螯","聱","鹌","锿","锕"};
String[] codeB={"鬓","鞴","魃","髌","髀","鳔","鳊","鲅","鐾 ","踣"};
String[] codeC={"黪","黜","魑","鲳","雠 ","龊"," 龀"," 躔"," 蹴"," 蹰"};
String[] codeD={"黩","黛","髑 ","骶 ","鞑 ","靼"," 鲽 ","鲷 ","貂 ","踱"}; Map<String, String[]> map = new HashMap<String, String[]>();
map.put("a", codeA);
map.put("b", codeB);
map.put("c", codeC);
map.put("d", codeD);
for(String key : map.keySet() ){
System.out.println(key + " " + map.get(key));
}
}
Iterator<String> iterator = keyset.iterator();
while(iterator.hasNext()){
System.out.println(iterator.next());
}
这个不就是把所有的键都输出吗,输出a b c d不是这样吗?
String[] codeA={"黯","鏖","鳌 ","鏊","霭","螯","聱","鹌","锿","锕"};
String[] codeB={"鬓","鞴","魃","髌","髀","鳔","鳊","鲅","鐾 ","踣"};
String[] codeC={"黪","黜","魑","鲳","雠 ","龊"," 龀"," 躔"," 蹴"," 蹰"};
String[] codeD={"黩","黛","髑 ","骶 ","鞑 ","靼"," 鲽 ","鲷 ","貂 ","踱"}; Map<String, String[]> map = new HashMap<String, String[]>();
map.put("a", codeA);
map.put("b", codeB);
map.put("c", codeC);
map.put("d", codeD);
for(String key : map.keySet() ){
System.out.println(key + " " + map.get(key));
}
}貌似这个不错。
String[] codeA={"黯","鏖","鳌 ","鏊","霭","螯","聱","鹌","锿","锕"};
String[] codeB={"鬓","鞴","魃","髌","髀","鳔","鳊","鲅","鐾 ","踣"};
String[] codeC={"黪","黜","魑","鲳","雠 ","龊"," 龀"," 躔"," 蹴"," 蹰"};
String[] codeD={"黩","黛","髑 ","骶 ","鞑 ","靼"," 鲽 ","鲷 ","貂 ","踱"}; Map<String, String[]> map = new HashMap<String, String[]>();
map.put("a", codeA);
map.put("b", codeB);
map.put("c", codeC);
map.put("d", codeD);
for (Entry<String, String[]> e : map.entrySet()) {
for (String v : e.getValue()) {
System.out.println(e.getKey()+":"+v);
}
}
}