Lambda as a combination of methods from the Predicate interface doesn't compile if it is written as one statement
问题 What is the difference between both these ways of lambda creation? Why doesn't the first one compile? Predicate<Integer> predicate = Predicate.isEqual(0).or(Predicate.isEqual(1)); Gives: error : incompatible types: Predicate<Object> cannot be converted to Predicate<Integer> = Predicate.isEqual(0).or(Predicate.isEqual(1)); Predicate<Integer> pred21 = Predicate.isEqual(0); Predicate<Integer> pred22 = pred21.or(Predicate.isEqual(1)); This one works. 回答1: Adding <Integer> before the isEqual