I'm calling a Scala method, from Java. And I need to make the conversion from Seq to List.
I can't modified the signature of the Scala method, so I can't used the asJavaCollection
method from scala.collection.JavaConversions._
Any ideas of how can I achieve this?
Using Scala 2.9.3
Since Scala 2.9, you shouldn't use implicits from
JavaConversions
since they are deprecated and will soon be removed. Instead, to convertSeq
into javaList
useconvert
package like this (although it doesn't look very nice):You're on the right track using
JavaConversions
, but the method you need for this particular conversion isseqAsJavaList
:(In case you want to do this conversion in Scala code)
You can use JavaConverters to make this really easy.
Since 2.12 this is the recommended way:
All other methods a
@deprecated("use JavaConverters or consider ToJavaImplicits", since="2.12.0")