作者:Syn良子 出处:http://www.cnblogs.com/cssdongl 转载请注明出处

用Scala编码的时候,经常会遇到scala集合和Java集合互相转换的case,特意mark一下,加深记忆

scala.collection.Iterable <=> java.lang.Iterable

scala.collection.Iterable <=> java.util.Collection

scala.collection.Iterator <=> java.util.{ Iterator, Enumeration }

scala.collection.mutable.Buffer <=> java.util.List

scala.collection.mutable.Set <=> java.util.Set

scala.collection.mutable.Map <=> java.util.{ Map, Dictionary }

scala.collection.mutable.ConcurrentMap <=> java.util.concurrent.ConcurrentMap

scala.collection.Seq  => java.util.List

scala.collection.mutable.Seq => java.util.List

scala.collection.Set  => java.util.Set

scala.collection.Map => java.util.Map

java.util.Properties => scala.collection.mutable.Map[String, String]

可以用 scala.collection.JavaConversions来快速实现转换,比如把Java的list快速转为scala的buffer