序言
@Test public void test1() { List<Student> list = new ArrayList<>(); Student s1 = new Student(); s1.setName("a"); s1.setAge(20); list.add(s1); Student s2 = new Student(); s2.setName("b"); s2.setAge(20); list.add(s2); Student s3 = new Student(); s3.setName("c"); s3.setAge(30); list.add(s3); List<Student> filterList = list.stream().filter(p -> p.getAge().equals(20)).collect(Collectors.toList()); filterList.forEach(item->{ System.out.println(item.getName()); });
资料
https://blog.csdn.net/bitcarmanlee/article/details/70195403