A functional interface is an interface that defines only one abstract method. To precisely define an interface as functional, the @FunctionalInterface annotation has been added, working like the @Override principle. It will indicate the intent and prevent the second abstract method from being defined in the interface. An interface can include as many default methods as you want and still remain functional, because default methods are not abstract. Functional interfaces Function<T,R>, DoubleFunction<R>, IntFunction<R> and LongFunction<R> Function<T,R> is an interface that implements a function that receives an instance of the T class as input and returns an instance of the R class at the output. The default methods can be used to build call chains (compose, andThen). Function<String, Integer> toInteger = Integer::valueOf; Function<String, String> backToString = toInteger.andThen(String::valueOf); backToString.apply("123"); ...
Comments
Post a Comment