Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to create the Map of Scala

Shulou Source: shulou.com Published: 2022-05-31 21:24:44 10月03日 Update

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)

Tags: Learning content dual variable in this case one-off one line at the same time multiple that is forms ideas situations zippers articles methods more knowledge knowledge points articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Redmi vpn OPPO Reno Shulou Technology