Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //三項関数(S×T×U→R)の自作インターフェース
- @FunctionalInterface
- interface TriFunction<S,T,U,R> {
- R apply(S s, T t, U u);
- }
- public class TriFunctionTest {
- public static void main(String[] args) {
- //3つ文字列を連結
- TriFunction<String,String,String,String> tf1 = (a,b,c) -> a+b+c;
- System.out.println(tf1.apply("foo","bar","baz"));
- //三項演算(条件分岐)
- TriFunction<Boolean, Number, Number, Number> tf2 = (cond, v, w) -> cond ? v : w;
- System.out.println(tf2.apply(true, 1, 2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement