You can read first part of this article here . We all have implemented methods to get maximum or minimum between two different values. A value can be anything, it can be a primitive or an object. It can be an integer or a string or a person object. We were doing this in an […]
How to use and implement apply and andThen functions provided by java.util.function.BinaryOperator in java
java.util.function.BinaryOperator is a Functional Interface, it has only one abstract method. It extends another Functional Interface java.util.function.BiFunction. It inherits apply and andThen methods from BiFunction, and adds two static factory methods maxBy and minBy. BinaryOperator is special case of BiFunction, where all the parameter types and return type are of the same data-type. This is how the method declaration looks like in […]
How to use java.util.function.Consumer functional interface in java – And different implementations using class, lambdas and method reference
Consumer is present in java.util.functions package. It is a Functional Interface . In this article, we will use different ways to provide implementations for this interface. The Consumer implementation will take a String-input and write it to console. The System.out.println method can be replaced with other writers, like it can modified to write the contents to a file or […]