map的遍历取得的值的顺序与map本身的类型有关。
(1)这种是按照哈希值输出的
(2)这种是按照map存放顺序输出的
Map<String,String> map2 = new LinkedHashMap<String,String>(); map2.put("mx_internal_uid","E3F5D833DC2D30C035EC55EBE000A374"); map2.put("name", "硝酸盐氮"); map2.put("num", "234"); Set<String> keys2 = map2.keySet(); for (String key2 : keys2) { System.out.println(key2); } System.out.println("-------------------------"); Iterator key2 = keys2.iterator(); while (key2.hasNext()){ System.out.println(key2.next()); }