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<Map.Entry<String, Integer>> list = new ArrayList(players.entrySet());
 Collections.sort(list, (s1,s2) -> (s1.getValue()-s2.getValue()));
 System.err.println(list.get(list.size()-1).getKey());
}

 

    原文作者:除不掉的灰色
    原文地址: https://blog.csdn.net/bug_love/article/details/89961915
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞