List<User> list = new ArrayList<>();
List<String> list2 = new ArrayList<>();
User user = new User();
user.setAge(1);
user.setName("zhangsan");
list.add(user);
list.stream().forEach(str -> {
list2.add(str.getName());
});
System.out.println(list2);
jdk1.8 steam foreach用法
最新推荐文章于 2024-07-17 15:12:32 发布