java7钻石语法

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

public class Test {

public static void main(String[] args) {
  //1.7jdk钻石语法
  HashMap map = new HashMap<>();
  map.put("1", "abc");
  map.put("2", "def");
  map.put("3", "ghi");
  Set> enstr = map.entrySet();
  for (Map.Entry it: enstr) {
      System.out.println(it.getKey() + it.getValue());
    }
  }
}

转载于:https://www.cnblogs.com/ergou/p/6891468.html

你可能感兴趣的:(java)