Java 8 - Filter with BiPredicate

Viewed 14016

I have a Stream of Integer and I would like to find the two numbers whose sum is equals to another number. So I came up with the following solution:

BiPredicate<Integer, Integer> p = (price1, price2) -> price1.intValue() + price2.intValue() == moneyQty;
flavoursPrices.filter(p);

But the filter method does not receive a BiPredicate. Why not? What is an alternative for that?

4 Answers
Related