The Scala collection and the Java collection type convert to each other:
http://www.scala-lang.org/api/current/index.html#scala.collection.javaconverters$
You can easily convert between Java and Scala collection types through the Javaconverters package. It asScala decorates the Scala collection with a method of decorating the common Java collection asJava .
Import scala.collection.javaconverters._ val sl = new Scala.collection.mutable.listbuffer[int] Val jl:java.util.List [Int] = Sl.asjava val Sl2:scala.collection.mutable.buffer[int] = Jl.asscala assert (SL eq SL2)
Bidirectional conversions:
scala.collection.iterable <=> java.lang.iterablescala.collection.iterable <=> java.util.collectionscala.collection.iterator <=> java.util. { iterator, enumeration }scala.collection.mutable.buffer <=> java.util.listscala.collection.mutable.set <=> java.util.setscala.collection.mutable.map <=> java.util. { map, dictionary }scala.collection.mutable.concurrentmap <=> Java.util.concurrent.ConcurrentMap
In addition, the following one-way conversions are provided
Scala.collection.Seq = Java.util.Listscala.collection.mutable.Seq = Java.util.Listscala.collection.Set = > Java.util.Setscala.collection.Map = Java.util.Map
This article from the "Down-to-earth, look at the Stars" blog, please be sure to keep this source http://xubcing.blog.51cto.com/3502962/1670030
Conversion of Scala collection types to Java