java获取list集合里面的集合指定数据

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);

效果

 

posted @ 2020-12-09 18:47  小小穿梭机^^  阅读(6007)  评论(0编辑  收藏  举报