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}的简称") } } } }