lambda 遍历map 数组

  Map<String,String> map=new HashMap<>();
        map.put("num1","123");
        map.put("num2","456");
        
        map.forEach((k, v) -> System.out.println("k " + k + " v " + v));

                      for (Map.Entry<String, String> entry : map.entrySet()) {
                         System.out.println("key= " + entry.getKey() + " and value= "
                                         + entry.getValue());
                     }


String[] atp = {"Rafael Nadal", "Novak Djokovic",
                "Stanislas Wawrinka",
                "David Ferrer","Roger Federer",
                "Andy Murray","Tomas Berdych",
                "Juan Martin Del Potro"};
        List<String> players =  Arrays.asList(atp);
        
        players.forEach((player) ->System.out.println(player));

 

    原文作者:文革爱自由
    原文地址: https://blog.csdn.net/qq_39977900/article/details/82185121
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞