Take a look at BiPredicate, I think it is what you are looking for. It takes two generic values, and returns a boolean.
In fact, Java 8 includes dozens of simple generic functional interfaces for various types of lambda expressions. For example, lambdas that return a type of a class reference, or take multiple parameters, etc. In fact, you can even write your own functional interfaces, then create lambda expressions for them. As long as the compiler has access to a matching functional interface, then it will accept the lambda expression.
For the OCA book, we only cover basic syntax and Predicate, because is what the exam requires. In our OCP book, though, we spent multiple chapters exploring functional interfaces, lambda expressions, and streams.
Ben Pittens wrote:Maybe you can commit the BiPredicate print function as an example to the book. Just a tip.
Appreciate the feedback, but BiPredicate is not part of the OCA exam. There are so many functional interfaces that we chose to focus on only the ones you need to know for the OCA exam. Don't worry, you'll see plenty of functional interfaces when studying for the OCP exam!
Ben Pittens wrote:But what if we have 2 variables, how does method print then look like?
When using lambdas the world is your oyster. And that's the beauty of this language feature. The only thing you need is a functional interface. In this topic all requirements for a functional interface are explained in great detail (with illustrative code snippets).
And here you'll have the TwoStrings functional interface (what's in a name? )And this functional interface can be used in the print method as illustrated in this code snippet defining two straightforward (easy) lambdas and a more complex oneOutput: