Scala的Map集合练习
package gxy import scala.collection.mutable object Test25 { def main(args: Array[String]): Unit = { //可变map val map1 = mutable.Map("123" -> "活着,余华,8888", "234" -> "朝花夕拾,鲁迅,7777", "456" -> "三体,刘慈欣,9999") println(map1) //1.添加 map1 += ("678" -> "某某,木苏里,6666", "789" -> "撒野,巫哲,2222") println(map1) val rs = map1.get("123") println(rs.get) println(map1("123")) map1("123") = "活着,余华,8888" for ((key, value) <- map1) { println(s"$key 是 ${value}的简称") val map2 = map1 - "123" -> "活着,余华,8888" for ((key, value) <- map1) { println(s"$key 是 ${value}的简称") } } } }
原文地址:https://blog.csdn.net/2401_83378805/article/details/143687774
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!