lambda表达式遍历

public static void main(String[] args) {
    Map players = new HashMap();
 players.put("wew",1212);
 players.put("wedenl",121);
 players.put("oo",120);
 // 1.2 使用 lambda expression 排序 players
 List> list = new ArrayList(players.entrySet());
 Collections.sort(list, (s1,s2) -> (s1.getValue()-s2.getValue()));
 System.err.println(list.get(list.size()-1).getKey());
}

 

你可能感兴趣的:(java分享)