Which is a valid statement?
Which is a valid statement?
The correct statement is 'BiPredicate testEquality = (var x, var y) -> (x.equals(y));'. This is because the 'var' keyword can be used for both parameters when declaring a lambda expression, ensuring that both variables have their types inferred properly. Mixing 'var' with explicit types, omitting parentheses, or incorrectly grouping the variable declarations would result in syntax errors or invalid syntax for lambda expressions.
similar to 22, 204
A) there is no mix var with the explicit types B) ok C) syntax error without brackets D) compound not allowed
B: Bcos Bipredicated is declared without type and then cannot pass other Type that Object
For backward compatibility, assigning a parameterized type to its raw type is allowed. BiPredicate is a raw type from generic type BiPredicate<T,U> where T and U substitute to Object. So it could be any type inherited from Object type.