lambda: functional interface can contain multiple default methods

This commit is contained in:
Anna Kozlova
2012-08-31 12:03:21 +04:00
parent 328aa58823
commit 2c05b4d750
3 changed files with 25 additions and 6 deletions

View File

@@ -0,0 +1,17 @@
class Test {
public static final BinaryOperator<Integer> rPlus = (x, y) -> x + y;
interface BinaryOperator<T> extends Combiner<T,T,T> {
public T operate(T left, T right);
@Override
T combine(T t1, T t2) default {
return operate(t1, t2);
}
}
interface Combiner<T, U, V> {
V combine(T t, U u);
}
}