Scala offers implicit conversions between all the major collection types in the JavaConverters object.
The following type conversions are bidirectional.
Scala Type | Java Type |
---|---|
Iterator | java.util.Iterator |
Iterator | java.util.Enumeration |
Iterator | java.util.Iterable |
Iterator | java.util.Collection |
mutable.Buffer | java.util.List |
mutable.Set | java.util.Set |
mutable.Map | java.util.Map |
mutable.ConcurrentMap | java.util.concurrent.ConcurrentMap |
Certain other Scala collections can also be converted to Java, but do not have a conversion back to the original Scala type:
Scala Type | Java Type |
---|---|
Seq | java.util.List |
mutable.Seq | java.util.List |
Set | java.util.Set |
Map | java.util.Map |
Reference:
Conversions Between Java and Scala Collections