allMatch anyMatch and noneMatch



import java.util.Arrays;
import java.util.List;

public class MatchFlight {

public static void main(String[] args) {

List<Integer> nums = Arrays.asList(1,2,3,4,5,6,7);

boolean allPositive = nums.stream().allMatch(num->num>0);
System.out.println("allPositive: "+allPositive);

boolean anyEvenAvailable = nums.stream().anyMatch(num->num%2==0);
System.out.println("anyEvenAvailable: "+anyEvenAvailable);

boolean noneNegative = nums.stream().noneMatch(num->num<0);
System.out.println("noneNegative: "+noneNegative);
}
}
Output:
allPositive: true
anyEvenAvailable: true
noneNegative: true

Exaplanation:
allMatch : It checks all for the elements in the stream match the provided filter condition.
anyMatch: It checks any element in the stream match the provided filter condition.
noneMatch: It check none element in the stream match the provided filter condition.