lambda 遍历map 数组

  Map 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 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 players =  Arrays.asList(atp);
        
        players.forEach((player) ->System.out.println(player));

 

你可能感兴趣的:(lambda 遍历map 数组)