Say I have a Predicate interface from java :
public interface Predicate<T> {
boolean test(T t);
default Predicate<T> negate() {
return (t) -> !test(t);
}
}
Now, two implementation are created Predicate1 and Predicate2 using lambda expressions and they will have 1 object created(assuming oracle jvm) corresponding to each expression like
Predicate1 = (t) -> {return false}.
Predicate2 = (t) -> {return false}.
How many objects will be created corresponding to negate()
function? Will it be one object per implementation. ie two(2) in this case as we have Predicate1 and Predicate2 or will it be just one ?