Answers for "checking if a value is present in two list java"

1

check if all values are same in list java

boolean allEqual = list.stream().distinct().limit(2).count() <= 1
Posted by: Guest on March-02-2021
0

java find if element of list in present in another list

list1.stream()
   .map(Object1::getProperty)
   .anyMatch(
     list2.stream()
       .map(Object2::getProperty)
       .collect(toSet())
       ::contains)

// Example with predicate
Predicate<Object> notInList1 = object -> list1.stream().noneMatch(object::equals);
List<Object> missingInList1 = list2.stream().filter(notInList1).collect(Collectors.toList());
Posted by: Guest on February-26-2020

Code answers related to "checking if a value is present in two list java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language