Map<String, Object>的循环
Map数据
HashMap map = new HashMap<>();
map.put("name", "张三");
map.put("age", 20);
map.put("sex", "男");
map.put("phone", "13800000000");
map.put("account", "123456789");
public static void main(String[] args) {
// 方法一:在日常开发中使用比较多的
for (Map.Entry entry : map.entrySet()) {
String s = "key====>" + entry.getKey() + ",value===>" + entry.getValue();
System.out.println(s);
}
}

public static void main(String[] args) {
// 方法二:在开发中我还没有见过使用这个的
Iterator> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = iterator.next();
String s = "key====>" + entry.getKey() + ",value===>" + entry.getValue();
System.out.println(s);
}
}

public static void main(String[] args) {
// 方法三:使用Java8新特性
map.forEach((key, value) -> System.out.println("key====>" + key + ",value===>" + value));
}