map集合之增强for循环遍历map.Entry<String,Integer> en : map.entrySet()

package com.day15.Map;

import java.util.HashMap;
import java.util.Map;

public class MapFive {

  public static void main(String[] args) {
    Map<String, Integer> ma=new HashMap<>();
    ma.put("Kobe",20);
    ma.put("KG",21);
    ma.put("PP",22);
    ma.put("Allen",23);
    for(Map.Entry<String,Integer> en:ma.entrySet()){
      System.out.print(en.getKey()+"="+en.getValue());//PP=22Kobe=20KG=21Allen=23
    }
  }

}

posted @ 2018-05-14 14:51  简简单单zjl  阅读(7476)  评论(0编辑  收藏  举报