Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两张地图:
我想创建第三个映射,它将保存来自上面映射的键值对,以便一次从上面两个映射中交替获取键值对。所以第三个映射将形成键为 1,2,3,4,5,6,7。
s3 = new HashMap(); s3.putAll(s1); s3.putAll(s2);
您可以使用自动对键进行排序的 TreeMap,并使用该putAll方法将原始映射的键/值对添加到新映射中。
putAll