We would like to know how to create Predicate and call and method.
/*from www .j ava2 s . com*/ import java.util.function.Predicate; public class Main { public static void main(String[] args) { Predicate<String> a = (input) -> input.contains("a"); Predicate<String> b = (input) -> input.contains("b"); System.out.println("test ac:" + a.and(b).test("ac")); System.out.println("test bc:" + a.and(b).test("bc")); System.out.println("test ab:" + a.and(b).test("ab")); } }
The code above generates the following result.