Java 8: Where is TriFunction (and kin) in java.util.function? Or what is the alternative?

后端 未结 7 1308
臣服心动
臣服心动 2020-11-30 17:46

I see java.util.function.BiFunction, so I can do this:

BiFunction f = (x, y) -> { return 0; };

What if

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-30 18:14

    You could also create your own function taking the 3 parameters

    @FunctionalInterface
    public interface MiddleInterface{
        boolean isBetween(F from, T to, V middleValue);
    }
    
    MiddleInterface middleInterface = 
    (x,y,z) -> x>=y && y<=z; // true
    

提交回复
热议问题