stream过滤和map的用法


    public static void main(String[] args) {
        List list = new ArrayList<>();
        list.add(new Pojo(1, "qx1"));
        list.add(new Pojo(2, "qx6"));
        list.add(new Pojo(3, "qx2"));
        list.add(new Pojo(5, "qx5"));
        list.add(new Pojo(6, "qx3"));
        list.add(new Pojo(4, "qx4"));
        List collect = list.stream().filter(x -> x.getAge() % 2 == 1).map(x -> {
            x.setName(x.getName() + "123");
            return x;
        }).collect(Collectors.toList());
        System.out.println(collect);
    }
 
  

你可能感兴趣的:(java,windows,开发语言)