June 2018
Beginner
722 pages
18h 47m
English
The Supplier interface does not have default methods, while the Predicate interface has one static method, isEqual(Object targetRef), and three default methods: and(Predicate other), negate(), and or(Predicate other). To demonstrate usage of the and(Predicate other) and or(Predicate other) methods, for example, let's write the methods that create two Predicate<Double> functions. One function checks whether the value is smaller than the input:
Predicate<Double> testSmallerThan(double limit){ Predicate<Double> func = new Predicate<Double>() { public boolean test(Double num) { System.out.println("Test if " + num + " is smaller than " + limit); return num < limit; } }; return func;}
Another function checks whether the value ...
Read now
Unlock full access