当前位置:网站首页>Lambda intermediate operation map

Lambda intermediate operation map

2022-06-12 00:42:00 Leon_ Jinhai_ Sun

map

​ The elements in the convection can be calculated or converted .

for example :

​ Print the names of all writers

        List<Author> authors = getAuthors();

        authors
                .stream()
                .map(author -> author.getName())
                .forEach(name->System.out.println(name));
//         Print the names of all writers 
        List<Author> authors = getAuthors();

//        authors.stream()
//                .map(author -> author.getName())
//                .forEach(s -> System.out.println(s));

        authors.stream()
                .map(author -> author.getAge())
                .map(age->age+10)
                .forEach(age-> System.out.println(age));

原网站

版权声明
本文为[Leon_ Jinhai_ Sun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206120036470627.html