This object provides extension methods that convert between Scala and Java function types.
When writing Java code, use the explicit conversion methods defined injavaapi.FunctionConverters instead.
Using the.asJava extension method on a Scala function produces the most specific possible Java function type:
scala> import scala.jdk.FunctionConverters._scala> val f = (x: Int) => x + 1scala> val jf1 = f.asJavajf1: java.util.function.IntUnaryOperator = ...More generic Java function types can be created using the correspondingasJavaXYZ extension method:
scala> val jf2 = f.asJavaFunctionjf2: java.util.function.Function[Int,Int] = ...scala> val jf3 = f.asJavaUnaryOperatorjf3: java.util.function.UnaryOperator[Int] = ...Converting a Java function to Scala is done using theasScala extension method:
scala> List(1,2,3).map(jf2.asScala)res1: List[Int] = List(2, 3, 4)