Answers for "java stream list contains a field"

2

java find item in list by property

Customer james = customers.stream()
  .filter(customer -> "James".equals(customer.getName()))
  .findAny()
  .orElse(null);
Posted by: Guest on February-19-2020
0

java list of a class has a string that is equal to

public boolean containsName(final List<MyObject> list, final String name){
    return list.stream().map(MyObject::getName).filter(name::equals).findFirst().isPresent();
}
Posted by: Guest on May-18-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language