What is the result of the following class?
1: import java.util.function.*; 2: 3: public class Main { 4: int age; 5: public static void main(String[] args) { 6: Main p1 = new Main(); 7: p1.age = 1; 8: check(p1, p -> p.age < 5); 9: } 10: private static void check(Main main, Predicate<Main> pred) { 11: String result = pred.test(main) ? "match" : "not match"; 12: System.out.print(result); 13: } 14:}
A.
Line 8 creates a lambda expression that checks if the age is less than 5.
Since there is only one parameter without a type, the parentheses around the type parameter are optional.
Line 10 uses the Predicate interface, which declares a test() method.