public static void main(String[] args) {ArrayList<HashMap<String, String>> array = new ArrayList<HashMap<String, String>>();HashMap<String, String> hm1 = new HashMap<String, String>();hm1.put("华为", "任正非");hm1.put("小米", "雷军");array.add(hm1);HashMap<String, String> hm2 = new HashMap<String, String>();hm2.put("腾讯", "马化腾");hm2.put("格力", "董明珠");array.add(hm2);HashMap<String, String> hm3 = new HashMap<String, String>();hm3.put("苹果", "库克");array.add(hm3);for (HashMap<String, String> hm : array) {//得到map的键值Set<String> keySet = hm.keySet();//遍历键值 通过键值得到valuefor (String key : keySet) {System.out.println(key + "---" + hm.get(key));}}}
600字范文,内容丰富有趣,生活中的好帮手!