package com.sk.demos;
import java.util.function.Predicate;
public class JoiningPredicates {
public static void main(String[] args) {
int a[] = { 0, 5, 10, 15, 12, 20, 25, 30 };
//1st predicate will check number is number even or not
//2nd predicate will check number>10
Predicate<Integer> p1 = e -> e % 2 == 0;
Predicate<Integer> p2 = e -> e > 10;
for (Integer intCheck : a) {
if (p1.and(p2).test(intCheck)) {
System.out.println(intCheck);
}
}
}
}
output:
===========
12
20
30
No comments:
Post a Comment