Alex Rivera | Logout

How to convert a scala.List to a java.util.List?

Asked 2010-03-12T01:37:17.903
135

How to convert Scala's scala.List into Java's java.util.List?

Edit
Report

1 Answer

1

For single invocations, doing it by hand might be the simplest solution:

val slist = List (1, 2, 3, 4)          
val jl = new java.util.ArrayList [Integer] (slist.size)
slist.foreach (jl.add (_))   

I didn't measure performance.

answered 2010-03-12T13:53:08.430

Your Answer