map put

Posted anitinaj

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了map put相关的知识,希望对你有一定的参考价值。

public class test {
static Map<String, Map<String, Integer>> mapB = new HashMap<String, Map<String, Integer>>();
static Map<String, Integer> mapA = new HashMap<String, Integer>();

public test() {
mapA.put("a", 66);
}
public static void main(String[] args) {
test t = new test();
System.out.println(mapA.get("a"));
t.tempA(mapA);
mapB.put("m", mapA);
mapA.put("a", 2);
mapA.put("b", 3);
System.out.println(mapA.get("a") + " --- " + mapA.get("b"));
System.out.println(mapB.get("m").keySet() + " ------ " + mapB.get("m"));
System.out.println(mapA.get("a") + " --- " + mapA.get("b"));

}

public void tempA(Map<String, Integer> mapC) {
mapC.put("a", 6);
}
}

运行结果:

66
2 --- 3
[a, b] ------ {a=2, b=3}
2 --- 3

以上是关于map put的主要内容,如果未能解决你的问题,请参考以下文章

Map

map put值 使用匿名函数

map的遍历方式

为啥map.put不维护键的顺序[重复]

map创建JSONObject对象

如何遍历Map操作总结