How to create the Map of Scala
This article mainly explains "how to create the Map of Scala". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to create the Map of Scala".
First, create a map. The default Map in the first line is immutable, and the second line is mutable.
Val map1 = Map ("bajie"-> 20, "wukong"-> "80", "wujing"-> 100)
Val map2 = scala.collection.mutable.Map ("bajie"-> 20, "wukong"-> "80", "wujing"-> 100)
Val map3 = new scala.collection.mutable.HashMap [String, Int]
Second, Map operation, find map1 ("bajie"), map1 ("bajie") = 30, and map1-= "bajie", map1 + = ("shifu"-> 1000)
Third, the iteration of map is 100 times simpler than that of java.
For (k, v)