Converting a Java collection into a Scala collection
If you want to be more explicit than the JavaConversions demonstrated in robinst's answer, you can use JavaConverters:
import scala.collection.JavaConverters._
val l = new java.util.ArrayList[java.lang.String]
val s = l.asScala.toSet
For future reference: With Scala 2.8, it could be done like this:
import scala.collection.JavaConversions._
val list = new java.util.ArrayList[String]()
list.add("test")
val set = list.toSet
set
is a scala.collection.immutable.Set[String]
after this.
Also see Ben James' answer for a more explicit way (using JavaConverters), which seems to be recommended now.