Java: Add some examples of functional interfaces for functions with two parameters.

This commit is contained in:
Michael Nebel
2022-10-06 14:26:01 +02:00
parent 3b109db2d1
commit 0cfd7787f4
2 changed files with 18 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
package p;
@FunctionalInterface
public interface MyFunction<T1, T2, T3> {
T3 apply(T1 x, T2 y);
}

View File

@@ -44,4 +44,16 @@ public class TypeBasedComplex<T> {
public void set(Integer x, Function<Integer, T> f) {
throw null;
}
public Integer applyMyFunction(MyFunction<T, Integer, T> f, Integer x) {
throw null;
}
public <S1, S2> S2 applyMyFunctionGeneric(MyFunction<T, S1, S2> f, S1 x) {
throw null;
}
public <S1, S2, S3> S3 applyMyFunctionGeneric(MyFunction<S1, S2, S3> f, S1 x, S2 y) {
throw null;
}
}