List<Book> list = Lists.newArrayList();
list.add(new Book("1", "sql基础大全", 200));
list.add(new Book("2", "Java基础", 500));
System.out.println(list);
List<String> nameList = list.stream().map(Book -> Book.getName()).collect(Collectors.toList());
System.out.println(nameList);
输出结果:
原文地址:https://www.cnblogs.com/kc19941205/p/12100958.html
时间: 2024-11-06 03:51:42