jdk1.8集合遍历

public static void main(String[] args) {
        List list = new ArrayList();
        list.add("java1");
        list.add("java2");
        list.add("java3");
        list.stream().forEach(System.out::println);

        Set set = new TreeSet();
        set.add("java");
        set.add("php");
        set.add("js");
        set.stream().forEach(System.out::println);

        Map map = new HashMap();
        map.put("key1","key1");
        map.put("key2","key2");
        map.put("key3","key3");
        map.forEach((k,v)-> {
            System.out.println(k+"---"+v);
        });
    }

你可能感兴趣的:(jdk1.8集合遍历)