object test2 { def main(args: Array[String]): Unit = { val im = scala.collection.immutable.Map(1->"one",2->"two") //不可变map val imh = scala.collection.immutable.HashMap(1->"one",2->"two") //不可变hashmap val mu = scala.collection.mutable.Map(1->"one",2->"two") //可变map println(im,manOf(im)) println(imh,manOf(imh)) println(mu,manOf(mu))
//mutable.Map to immutable.Map val mui = mu.toMap println(mui,manOf(mui))
//immutable.Map to mutable.Map val immu = scala.collection.mutable.Map(im.toSeq:_*) println(immu,manOf(immu)) val imhmu = scala.collection.mutable.Map(imh.toSeq:_*) println(imhmu,manOf(imhmu))
}
//查看数据类型方法-manOf(data) def manOf[T:Manifest](t:T):Manifest[T]=manifest[T] }
|