List<Student> list = Arrays.asList(new Student(1l, "one"), new Student(2l, "two"), new Student(3l, "tree"));
//从list集合中,取出字段name的列表
List<String> names = list.stream().map(p -> p.getHome()).collect(Collectors.toList());
System.out.println(names);
java8 从对象集合中取出某个字段的集合
最新推荐文章于 2024-07-15 03:46:34 发布