static void main(String[] args){
list();
}
public static void list(){
List<User> list1 = new ArrayList<>();
List<String> list2 = new ArrayList<>();
User user1 = new User();
user1.setName("李四");
user1.setPhone("123");
list1.add(user1);
User user2 = new User();
user2.setName("张三");
user2.setPhone("234");
list1.add(user2);
//把user的Name全部拉出来存放到list2中
list2 = list1.stream().map(user->{
return user.getName();
}).collect(Collectors.toList());
}