Advertisement
Guest User

Untitled

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