How to convert Scala List [Double] to java.util.List [java.lang.Double]?

I saw only examples in which the result is a Java list from Scala double. I got to

def getDistance(): java.util.List[java.lang.Double] = { val javadistance = distance.toList.asJava javadistance } 

but this is still a Java list containing Scala doubleles ( distance is a member of the same class as getDistance ).

+1
source share
1 answer

You need to use the java boxed option on the map:

  def getDistance(): java.util.List[java.lang.Double] = { distance.toList.map(Double.box).asJava } 
+3
source

Source: https://habr.com/ru/post/969730/


All Articles