From 6f34650e2de2cdfd9993a59b840ac3aba28740f2 Mon Sep 17 00:00:00 2001 From: luming Date: Wed, 30 Jun 2021 17:03:41 +0800 Subject: [PATCH] =?UTF-8?q?map=E9=9B=86=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/senior/Collection/CollectioMap.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/senior/Collection/CollectioMap.kt diff --git a/src/senior/Collection/CollectioMap.kt b/src/senior/Collection/CollectioMap.kt new file mode 100644 index 0000000..3035e97 --- /dev/null +++ b/src/senior/Collection/CollectioMap.kt @@ -0,0 +1,16 @@ +package senior.Collection + +fun main(args: Array) { + // 不可变map + var m: Map = mapOf("a" to "A", "b" to "B", "c" to "C") + println(m) + + println(m.get("a")) + // 可变map + var map: MutableMap = mutableMapOf() + map.put("cat", "猫") + map.put("pig", "猪") + println(map) + + println(map.get("pig")) +} \ No newline at end of file