Questions tagged «scala-2.7»

10
将Java集合转换为Scala集合
与Stack Overflow问题Scala与新的HashSet(Collection)等效,我如何将Java集合(java.util.List例如)转换为Scala集合List? 我实际上是在尝试将Java API调用转换为Spring的 SimpleJdbcTemplate(返回a java.util.List<T>)成不可变的Scala HashSet。因此,例如: val l: java.util.List[String] = javaApi.query( ... ) val s: HashSet[String] = //make a set from l 这似乎有效。欢迎批评! import scala.collection.immutable.Set import scala.collection.jcl.Buffer val s: scala.collection.Set[String] = Set(Buffer(javaApi.query( ... ) ) : _ *)
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.