• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

lambda 遍历map 数组

java 来源:qq_39977900 1次浏览
  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));

 


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)