package com.cy.market.async;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class Test {
public static void main(String[] args) {
seach();
}
public static List seach(){
List list = new ArrayList<>();
Student student = new Student();
student.setAge(1);
student.setName(“张三”);
list.add(student);
Student student1 = new Student();
student1.setAge(2);
student1.setName(“李四”);
list.add(student1);
Student student2 = new Student();
student2.setAge(3);
student2.setName(“三娃”);
list.add(student2);
List result1 = list.stream()
.filter(item -> item.getName().contains(“三”))
.collect(Collectors.toList());
System.out.println(list);
System.out.println(result1);
return result1;
}
@Data
public static class Student{
private String name;
private Integer age;
}
}