Related to this question, how do convert a Java collection (java.util.List
say) into a scala collection List
?
EDIT; what I am actually trying to do is convert a Java API call to Spring's SimpleJdbcTemplate
, which returns a java.util.List<T>
, into a scala immutable HashSet
. So for example:
val l: java.util.List[String] = javaApi.query( ... )
val s: HashSet[String] = //make a set from l
EDIT AGAIN. This seems to work. Criticism welcome!
import scala.collection.immutable.Set
import scala.collection.jcl.Buffer
val s: scala.collection.Set[String] =
Set(Buffer(javaApi.query( ... ) ) : _ *)