public class User{
private int id;
private String name;
}
List userList= new ArrayList<>();
userList.add(new User(1, “小明”));
userList.add(new User(2, “小红”));
User user = userList.stream() .filter(user-> “小明”.equals(customer.getName())) .findAny() .orElse(null);