Java 8 – Functional interfaces with TWO method argument – EXAMPLES (java.util.function package)

This articles provide good examples of all functional interfaces with TWO method arguments from java.util.function package. It covers all methods in interfaces.

 

Functional Interface Both Method Arguments Return
java.util.function.BiConsumer Any type No return
java.util.function.BiFunction Any type Any Type
java.util.function.BinaryOperator Both Same type Same type as method arguments
java.util.function.BiPredicate Any type boolean (Primitive)
java.util.function.DoubleBinaryOperator double (Primitive) double (Primitive)
java.util.function.IntBinaryOperator int (Primitive) int (Primitive)
java.util.function.LongBinaryOperator long (Primitive) long (Primitive)

java.util.function.BiConsumer Examples

  • Method arguments = 2 arguments of any type
  • Method Return = No return value

java.util.function.BiFunction Examples

  • Method arguments = 2 arguments of any type
  • Method Return = Return value of any type

java.util.function.BinaryOperator Examples

  • Method arguments = 2 arguments of exact same type
  • Method Return = Return value of exact same type as that of method arguments

java.util.function.BiPredicate Examples

  • Method arguments = 2 arguments of any type
  • Method Return = boolean (Primitive)

java.util.function.DoubleBinaryOperator Examples

  • Method arguments = 2 arguments of double (Primitive)  type
  • Method Return = double (Primitive)

java.util.function.IntBinaryOperator Examples

  • Method arguments = 2 arguments of int (Primitive) type
  • Method Return = int (Primitive)

java.util.function.LongBinaryOperator Examples

  • Method arguments = 2 arguments of long (Primitive) type
  • Method Return = dlong (Primitive)

 

 

 

 

Leave a Reply

Your email address will not be published.