{"id":102920,"date":"2026-09-09T17:49:02","date_gmt":"2026-09-09T09:49:02","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/102920.html"},"modified":"2026-09-09T17:49:02","modified_gmt":"2026-09-09T09:49:02","slug":"java-%e9%9b%86%e5%90%88%ef%bc%9amap-%e6%8e%a5%e5%8f%a3%e5%ae%8c%e6%95%b4%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/102920.html","title":{"rendered":"Java \u96c6\u5408\uff1aMap \u63a5\u53e3\u5b8c\u6574\u7b14\u8bb0"},"content":{"rendered":"<h2>\u4e00\u3001Map \u96c6\u5408\u4f53\u7cfb<\/h2>\n<p>Map \u662f Map \u96c6\u5408\u4f53\u7cfb\u7684\u6839\u63a5\u53e3<\/p>\n<h3>a) Map \u96c6\u5408\u7279\u70b9<\/h3>\n<li>\u952e\u503c\u5bf9\u5b58\u50a8key\u2011value&#xff0c;\u4e00\u4e2a\u952e\u503c\u5bf9\u5c31\u662f Map \u96c6\u5408\u5f53\u4e2d\u7684\u4e00\u4e2a\u5143\u7d20<\/li>\n<li>key&#xff08;\u952e&#xff09;&#xff1a;\u65e0\u5e8f\u3001\u65e0\u4e0b\u6807&#xff0c;\u5143\u7d20\u4e0d\u5141\u8bb8\u91cd\u590d&#xff0c;\u5177\u6709\u552f\u4e00\u6027<\/li>\n<li>value&#xff08;\u503c&#xff09;&#xff1a;\u65e0\u5e8f\u3001\u65e0\u4e0b\u6807&#xff0c;\u5143\u7d20\u5141\u8bb8\u91cd\u590d<\/li>\n<h3>b) \u5e38\u7528\u65b9\u6cd5<\/h3>\n<li>V put(K key,V value) \u5f80 Map \u96c6\u5408\u6dfb\u52a0\u952e\u503c\u5bf9\u3002<\/li>\n<ul>\n<li>\u5982\u679c\u96c6\u5408\u4e2d\u4e0d\u5b58\u5728\u8be5 key&#xff1a;\u76f4\u63a5\u65b0\u589e&#xff0c;\u8fd4\u56denull<\/li>\n<li>\u5982\u679c\u96c6\u5408\u5df2\u7ecf\u5b58\u5728\u8be5 key&#xff1a;\u65b0 value \u8986\u76d6\u65e7 value&#xff0c;\u8fd4\u56de\u88ab\u8986\u76d6\u7684\u65e7 value<\/li>\n<\/ul>\n<p>\u2b50\u5f00\u53d1\u91cd\u70b9\u65b9\u6cd5<\/p>\n<li>V remove(K key) \u6839\u636e\u952e\u5220\u9664\u5bf9\u5e94\u7684\u952e\u503c\u5bf9&#xff0c;\u8fd4\u56de\u88ab\u5220\u9664\u7684 value\u3002<\/li>\n<li>V get(K key) \u6839\u636e key \u83b7\u53d6\u5bf9\u5e94\u7684 value\u3002\u2b50\u91cd\u70b9<\/li>\n<li>int size() \u83b7\u53d6 Map \u5f53\u4e2d\u952e\u503c\u5bf9\u7684\u603b\u4e2a\u6570\u3002<\/li>\n<li>boolean containsKey(K key) \u5224\u65ad\u96c6\u5408\u662f\u5426\u5305\u542b\u6307\u5b9a key&#xff0c;\u5b58\u5728\u8fd4\u56de true&#xff0c;\u4e0d\u5b58\u5728\u8fd4\u56de false\u3002<\/li>\n<li>boolean containsValue(V value) \u5224\u65ad\u96c6\u5408\u662f\u5426\u5305\u542b\u6307\u5b9a value&#xff0c;\u5b58\u5728\u8fd4\u56de true&#xff0c;\u4e0d\u5b58\u5728\u8fd4\u56de false\u3002<\/li>\n<h4>\u5e38\u7528\u65b9\u6cd5\u5b8c\u6574\u4ee3\u7801\u793a\u4f8b<\/h4>\n<p>import java.util.HashMap;<br \/>\nimport java.util.Map;<\/p>\n<p>public class MapDemo {<br \/>\n    public static void main(String[] args) {<br \/>\n        Map&lt;String, Integer&gt; map &#061; new HashMap&lt;&gt;();<\/p>\n<p>        \/\/ 1.put \u6dfb\u52a0\u952e\u503c\u5bf9<br \/>\n        map.put(&#034;\u5f20\u4e09&#034;, 18);<br \/>\n        map.put(&#034;\u674e\u56db&#034;, 20);<br \/>\n        Integer oldValue &#061; map.put(&#034;\u5f20\u4e09&#034;, 25); \/\/ key\u5df2\u5b58\u5728&#xff0c;\u8986\u76d6\u65e7\u503c&#xff0c;\u8fd4\u56de18<br \/>\n        System.out.println(&#034;\u88ab\u8986\u76d6\u7684\u65e7\u503c&#xff1a;&#034; &#043; oldValue);<\/p>\n<p>        \/\/ 2.size \u83b7\u53d6\u952e\u503c\u5bf9\u4e2a\u6570<br \/>\n        System.out.println(&#034;\u96c6\u5408\u5927\u5c0f&#xff1a;&#034; &#043; map.size());<\/p>\n<p>        \/\/ 3.get \u6839\u636ekey\u83b7\u53d6value<br \/>\n        System.out.println(&#034;\u5f20\u4e09\u7684\u5e74\u9f84&#xff1a;&#034; &#043; map.get(&#034;\u5f20\u4e09&#034;));<\/p>\n<p>        \/\/ 4.containsKey \u5224\u65ad\u662f\u5426\u5305\u542bkey<br \/>\n        System.out.println(&#034;\u662f\u5426\u5305\u542b\u738b\u4e94&#xff1a;&#034; &#043; map.containsKey(&#034;\u738b\u4e94&#034;));<\/p>\n<p>        \/\/ 5.containsValue \u5224\u65ad\u662f\u5426\u5305\u542bvalue<br \/>\n        System.out.println(&#034;\u662f\u5426\u5305\u542b\u5e74\u9f8425&#xff1a;&#034; &#043; map.containsValue(25));<\/p>\n<p>        \/\/ 6.remove \u6839\u636ekey\u5220\u9664<br \/>\n        Integer removed &#061; map.remove(&#034;\u674e\u56db&#034;);<br \/>\n        System.out.println(&#034;\u88ab\u5220\u9664\u7684\u503c&#xff1a;&#034; &#043; removed);<br \/>\n    }<br \/>\n}<\/p>\n<h3>c) Map \u5b9e\u73b0\u7c7b<\/h3>\n<p>\u5982\u679c\u81ea\u5b9a\u4e49\u7c7b\u5bf9\u8c61\u4f5c\u4e3a HashMap \u7684\u952e&#xff0c;\u4e3a\u4fdd\u8bc1 key \u4e0d\u91cd\u590d&#xff0c;\u5bf9\u5e94\u7c7b\u5fc5\u987b\u91cd\u5199hashCode()\u548cequals()\u3002 \u5f00\u53d1\u4e2d\u4e00\u822c\u4f18\u5148\u4f7f\u7528String\u3001Integer\u4f5c\u4e3a key&#xff08;\u7528\u6237\u540d\u3001id \u7b49&#xff09;&#xff0c;\u68c0\u7d22\u6548\u7387\u66f4\u9ad8\u3002<\/p>\n<li>HashMap JDK1.2&#xff0c;\u7ebf\u7a0b\u4e0d\u5b89\u5168&#xff0c;\u8fd0\u884c\u6548\u7387\u9ad8&#xff1b;\u5141\u8bb8null\u4f5c\u4e3a\u952e\u3001\u5141\u8bb8null\u4f5c\u4e3a\u503c\u3002<\/li>\n<p>\u5e95\u5c42\u7ed3\u6784&#xff1a;JDK1.8 \u4e4b\u524d &#061; \u6570\u7ec4 &#043; \u94fe\u8868&#xff1b;JDK1.8 \u53ca\u4e4b\u540e &#061; \u6570\u7ec4 &#043; \u94fe\u8868 &#043; \u7ea2\u9ed1\u6811&#xff08;\u94fe\u8868\u957f\u5ea6\u8d85\u8fc7 8 \u4e14\u6570\u7ec4\u957f\u5ea6\u226564 \u65f6\u8f6c\u7ea2\u9ed1\u6811&#xff09;<\/p>\n<li>Hashtable JDK1.0&#xff0c;\u7ebf\u7a0b\u5b89\u5168&#xff0c;\u8fd0\u884c\u6548\u7387\u6162&#xff1b;\u4e0d\u5141\u8bb8null\u4f5c\u4e3a\u952e\u548c\u503c\u3002<\/li>\n<p>&#x1f4dd;\u9762\u8bd5\u9898&#xff1a;\u5199\u51fa HashMap \u548c Hashtable \u7684\u533a\u522b<\/p>\n<p>\u8868\u683c<\/p>\n<table>\n<tr>\u5bf9\u6bd4\u7ef4\u5ea6HashMapHashtable<\/tr>\n<tbody>\n<tr>\n<td>\u51fa\u73b0\u7248\u672c<\/td>\n<td>JDK1.2<\/td>\n<td>JDK1.0<\/td>\n<\/tr>\n<tr>\n<td>\u7ebf\u7a0b\u5b89\u5168<\/td>\n<td>\u4e0d\u5b89\u5168&#xff0c;\u6548\u7387\u9ad8<\/td>\n<td>\u5b89\u5168&#xff0c;\u65b9\u6cd5\u52a0 synchronized&#xff0c;\u6548\u7387\u4f4e<\/td>\n<\/tr>\n<tr>\n<td>null \u952e \/null \u503c<\/td>\n<td>\u90fd\u5141\u8bb8<\/td>\n<td>\u90fd\u4e0d\u5141\u8bb8&#xff0c;\u629b NullPointerException<\/td>\n<\/tr>\n<tr>\n<td>\u7236\u7c7b<\/td>\n<td>AbstractMap<\/td>\n<td>Dictionary<\/td>\n<\/tr>\n<tr>\n<td>\u8fed\u4ee3\u5668<\/td>\n<td>Iterator&#xff08;fail-fast \u5feb\u901f\u5931\u8d25&#xff09;<\/td>\n<td>Enumerator<\/td>\n<\/tr>\n<tr>\n<td>\u9ed8\u8ba4\u521d\u59cb\u5bb9\u91cf<\/td>\n<td>16<\/td>\n<td>11<\/td>\n<\/tr>\n<tr>\n<td>\u6269\u5bb9\u673a\u5236<\/td>\n<td>2 \u500d<\/td>\n<td>2 \u500d &#043; 1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<li>LinkedHashMap HashMap \u7684\u5b50\u7c7b&#xff0c;\u53ef\u4ee5\u4fdd\u7559\u5143\u7d20\u7684\u6dfb\u52a0\u987a\u5e8f&#xff1b;\u5e95\u5c42 &#061; HashMap &#043; \u53cc\u5411\u94fe\u8868\u3002<\/li>\n<li>Properties Hashtable \u7684\u5b50\u7c7b&#xff0c;key \u4e0e value \u90fd\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u7c7b\u578b&#xff1b;\u5e38\u7528\u4e8e\u8bfb\u53d6\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6.properties\u3002<\/li>\n<p>import java.util.Properties;<br \/>\nimport java.io.FileInputStream;<\/p>\n<p>public class PropertiesDemo {<br \/>\n    public static void main(String[] args) throws Exception {<br \/>\n        Properties prop &#061; new Properties();<br \/>\n        \/\/ \u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6<br \/>\n        prop.load(new FileInputStream(&#034;config.properties&#034;));<br \/>\n        \/\/ \u6839\u636ekey\u83b7\u53d6value<br \/>\n        String username &#061; prop.getProperty(&#034;username&#034;);<br \/>\n        System.out.println(username);<br \/>\n    }<br \/>\n}<\/p>\n<li>TreeMap SortedMap \u63a5\u53e3\u5b9e\u73b0\u7c7b&#xff0c;\u53ef\u4ee5\u5bf9\u96c6\u5408\u4e2d\u7684 key \u8fdb\u884c\u6392\u5e8f&#xff1b;key \u5fc5\u987b\u5b9e\u73b0 Comparable \u63a5\u53e3\u6216\u4f20\u5165 Comparator \u6bd4\u8f83\u5668\u3002<\/li>\n<h3>d) Map \u4e09\u79cd\u904d\u5386\u65b9\u5f0f<\/h3>\n<p>Map \u672c\u8eab\u6ca1\u6709\u7d22\u5f15&#xff0c;\u4e0d\u80fd\u76f4\u63a5 for \u5faa\u73af\u904d\u5386&#xff0c;\u63d0\u4f9b\u4e09\u79cd\u904d\u5386\u65b9\u6848<\/p>\n<h4>\u2460 \u952e\u904d\u5386 keySet ()<\/h4>\n<p>\u83b7\u53d6\u5168\u90e8 key \u7ec4\u6210 Set \u96c6\u5408&#xff0c;\u518d\u901a\u8fc7 key \u8c03\u7528 get () \u62ff\u5230 value<\/p>\n<p>Set&lt;K&gt; ks &#061; map.keySet();<br \/>\nfor(K key : ks){<br \/>\n    V value &#061; map.get(key);<br \/>\n    System.out.println(key &#043; &#034; &#061; &#034; &#043; value);<br \/>\n}<\/p>\n<h4>\u2461 \u503c\u904d\u5386 values ()<\/h4>\n<p>\u53ea\u83b7\u53d6\u96c6\u5408\u4e2d\u6240\u6709 value&#xff0c;\u62ff\u4e0d\u5230 key<\/p>\n<p>Collection&lt;V&gt; vs &#061; map.values();<br \/>\nfor(V value : vs){<br \/>\n    System.out.println(value);<br \/>\n}<\/p>\n<p>\u6ce8\u610f&#xff1a;Map \u6ca1\u6709\u901a\u8fc7 value \u53cd\u5411\u83b7\u53d6 key \u7684\u65b9\u6cd5<\/p>\n<h4>\u2462 \u952e\u503c\u5bf9\u904d\u5386 entrySet ()&#xff08;\u6548\u7387\u8f83\u9ad8&#xff0c;\u63a8\u8350&#xff09;<\/h4>\n<p>\u628a\u6bcf\u4e00\u7ec4key\u2011value\u5c01\u88c5\u4e3aMap.Entry\u5bf9\u8c61<\/p>\n<p>Set&lt;Map.Entry&lt;K,V&gt;&gt; kvs &#061; map.entrySet();<br \/>\nfor(Map.Entry&lt;K,V&gt; kv : kvs){<br \/>\n    K key &#061; kv.getKey();<br \/>\n    V value &#061; kv.getValue();<br \/>\n    System.out.println(key &#043; &#034; &#061; &#034; &#043; value);<br \/>\n}<\/p>\n<h4>\u4e09\u79cd\u904d\u5386\u5b8c\u6574\u53ef\u8fd0\u884c\u4ee3\u7801<\/h4>\n<p>import java.util.*;<\/p>\n<p>public class MapIterator {<br \/>\n    public static void main(String[] args) {<br \/>\n        Map&lt;String, Integer&gt; map &#061; new HashMap&lt;&gt;();<br \/>\n        map.put(&#034;Java&#034;, 100);<br \/>\n        map.put(&#034;Python&#034;, 95);<br \/>\n        map.put(&#034;C&#043;&#043;&#034;, 90);<\/p>\n<p>        \/\/ \u65b9\u5f0f1&#xff1a;keySet \u952e\u904d\u5386<br \/>\n        System.out.println(&#034;&#061;&#061;&#061;&#061;&#061; keySet\u904d\u5386 &#061;&#061;&#061;&#061;&#061;&#034;);<br \/>\n        Set&lt;String&gt; keys &#061; map.keySet();<br \/>\n        for (String key : keys) {<br \/>\n            System.out.println(key &#043; &#034; -&gt; &#034; &#043; map.get(key));<br \/>\n        }<\/p>\n<p>        \/\/ \u65b9\u5f0f2&#xff1a;values \u503c\u904d\u5386<br \/>\n        System.out.println(&#034;&#061;&#061;&#061;&#061;&#061; values\u904d\u5386 &#061;&#061;&#061;&#061;&#061;&#034;);<br \/>\n        Collection&lt;Integer&gt; values &#061; map.values();<br \/>\n        for (Integer value : values) {<br \/>\n            System.out.println(value);<br \/>\n        }<\/p>\n<p>        \/\/ \u65b9\u5f0f3&#xff1a;entrySet \u952e\u503c\u5bf9\u904d\u5386&#xff08;\u63a8\u8350&#xff09;<br \/>\n        System.out.println(&#034;&#061;&#061;&#061;&#061;&#061; entrySet\u904d\u5386 &#061;&#061;&#061;&#061;&#061;&#034;);<br \/>\n        Set&lt;Map.Entry&lt;String, Integer&gt;&gt; entries &#061; map.entrySet();<br \/>\n        for (Map.Entry&lt;String, Integer&gt; entry : entries) {<br \/>\n            System.out.println(entry.getKey() &#043; &#034; -&gt; &#034; &#043; entry.getValue());<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<hr \/>\n<h2>\u4e8c\u3001HashMap \u9ad8\u9891\u9762\u8bd5\u9898\u8865\u5145<\/h2>\n<h3>1. HashMap \u5e95\u5c42\u539f\u7406<\/h3>\n<ul>\n<li>JDK1.7&#xff1a;\u6570\u7ec4 &#043; \u94fe\u8868&#xff0c;\u5934\u63d2\u6cd5<\/li>\n<li>JDK1.8&#xff1a;\u6570\u7ec4 &#043; \u94fe\u8868 &#043; \u7ea2\u9ed1\u6811&#xff0c;\u5c3e\u63d2\u6cd5<\/li>\n<li>\u94fe\u8868\u8f6c\u7ea2\u9ed1\u6811\u6761\u4ef6&#xff1a;\u94fe\u8868\u957f\u5ea6 \u2265 8 \u4e14 \u6570\u7ec4\u957f\u5ea6 \u2265 64<\/li>\n<li>\u7ea2\u9ed1\u6811\u9000\u5316\u4e3a\u94fe\u8868\u6761\u4ef6&#xff1a;\u8282\u70b9\u6570 \u2264 6<\/li>\n<\/ul>\n<h3>2. HashMap \u6269\u5bb9\u673a\u5236<\/h3>\n<ul>\n<li>\u9ed8\u8ba4\u521d\u59cb\u5bb9\u91cf&#xff1a;16<\/li>\n<li>\u8d1f\u8f7d\u56e0\u5b50&#xff1a;0.75<\/li>\n<li>\u6269\u5bb9\u9608\u503c &#061; \u5bb9\u91cf \u00d7 \u8d1f\u8f7d\u56e0\u5b50 &#061; 16 \u00d7 0.75 &#061; 12<\/li>\n<li>\u5143\u7d20\u4e2a\u6570\u8fbe\u5230\u9608\u503c\u65f6&#xff0c;\u6269\u5bb9\u4e3a\u539f\u6765\u76842 \u500d<\/li>\n<li>\u6269\u5bb9\u65f6\u4f1a\u91cd\u65b0\u8ba1\u7b97\u6240\u6709\u5143\u7d20\u7684 hash \u4f4d\u7f6e&#xff08;rehash&#xff09;<\/li>\n<\/ul>\n<h3>3. HashMap \u4e3a\u4ec0\u4e48\u7ebf\u7a0b\u4e0d\u5b89\u5168&#xff1f;<\/h3>\n<ul>\n<li>\u591a\u7ebf\u7a0b\u540c\u65f6 put \u53ef\u80fd\u5bfc\u81f4\u6570\u636e\u8986\u76d6<\/li>\n<li>JDK1.7 \u6269\u5bb9\u65f6\u5934\u63d2\u6cd5\u53ef\u80fd\u5bfc\u81f4\u94fe\u8868\u6210\u73af&#xff0c;\u6b7b\u5faa\u73af<\/li>\n<li>\u89e3\u51b3\u65b9\u6848&#xff1a;ConcurrentHashMap&#xff08;\u63a8\u8350&#xff09;\u3001Hashtable\u3001Collections.synchronizedMap()<\/li>\n<\/ul>\n<h3>4. \u81ea\u5b9a\u4e49\u5bf9\u8c61\u4f5c\u4e3a key \u6ce8\u610f\u4e8b\u9879<\/h3>\n<p>\u5fc5\u987b\u540c\u65f6\u91cd\u5199hashCode()\u548cequals()&#xff1a;<\/p>\n<ul>\n<li>hashCode \u76f8\u540c&#xff1a;\u5bf9\u8c61\u4e0d\u4e00\u5b9a\u76f8\u540c&#xff0c;\u9700\u8981\u518d\u7528 equals \u5224\u65ad<\/li>\n<li>equals \u76f8\u540c&#xff1a;hashCode \u4e00\u5b9a\u76f8\u540c<\/li>\n<li>\u53ea\u91cd\u5199 equals \u4e0d\u91cd\u5199 hashCode&#xff1a;\u4e24\u4e2a\u903b\u8f91\u76f8\u7b49\u7684\u5bf9\u8c61\u4f1a\u88ab\u5b58\u5230\u4e0d\u540c\u4f4d\u7f6e&#xff0c;\u65e0\u6cd5\u53bb\u91cd<\/li>\n<\/ul>\n<p>class Student {<br \/>\n    private String name;<br \/>\n    private int age;<\/p>\n<p>    &#064;Override<br \/>\n    public boolean equals(Object o) {<br \/>\n        if (this &#061;&#061; o) return true;<br \/>\n        if (o &#061;&#061; null || getClass() !&#061; o.getClass()) return false;<br \/>\n        Student student &#061; (Student) o;<br \/>\n        return age &#061;&#061; student.age &amp;&amp; Objects.equals(name, student.name);<br \/>\n    }<\/p>\n<p>    &#064;Override<br \/>\n    public int hashCode() {<br \/>\n        return Objects.hash(name, age);<br \/>\n    }<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001Map \u96c6\u5408\u4f53\u7cfb Map \u662f Map \u96c6\u5408\u4f53\u7cfb\u7684\u6839\u63a5\u53e3 a) Map \u96c6\u5408\u7279\u70b9<br \/>\n\u952e\u503c\u5bf9\u5b58\u50a8key\u2011value&#xff0c;\u4e00\u4e2a\u952e\u503c\u5bf9\u5c31\u662f Map \u96c6\u5408\u5f53\u4e2d\u7684\u4e00\u4e2a\u5143\u7d20key&#xff08;\u952e&#xff09;&#xff1a;\u65e0\u5e8f\u3001\u65e0\u4e0b\u6807&#xff0c;\u5143\u7d20\u4e0d\u5141\u8bb8\u91cd\u590d&#xff0c;\u5177\u6709\u552f\u4e00\u6027value&#xff08;\u503c&#xff09;&#xff1a;\u65e0\u5e8f\u3001\u65e0\u4e0b\u6807&#xff0c;\u5143\u7d20\u5141\u8bb8\u91cd\u590d<br \/>\nb) \u5e38\u7528\u65b9\u6cd5<br \/>\nV put(K key,V value) \u5f80 Map \u96c6\u5408\u6dfb\u52a0<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99],"topic":[],"class_list":["post-102920","post","type-post","status-publish","format-standard","hentry","category-server","tag-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java \u96c6\u5408\uff1aMap \u63a5\u53e3\u5b8c\u6574\u7b14\u8bb0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/102920.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java \u96c6\u5408\uff1aMap \u63a5\u53e3\u5b8c\u6574\u7b14\u8bb0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001Map \u96c6\u5408\u4f53\u7cfb Map \u662f Map \u96c6\u5408\u4f53\u7cfb\u7684\u6839\u63a5\u53e3 a) Map \u96c6\u5408\u7279\u70b9 \u952e\u503c\u5bf9\u5b58\u50a8key\u2011value&#xff0c;\u4e00\u4e2a\u952e\u503c\u5bf9\u5c31\u662f Map \u96c6\u5408\u5f53\u4e2d\u7684\u4e00\u4e2a\u5143\u7d20key&#xff08;\u952e&#xff09;&#xff1a;\u65e0\u5e8f\u3001\u65e0\u4e0b\u6807&#xff0c;\u5143\u7d20\u4e0d\u5141\u8bb8\u91cd\u590d&#xff0c;\u5177\u6709\u552f\u4e00\u6027value&#xff08;\u503c&#xff09;&#xff1a;\u65e0\u5e8f\u3001\u65e0\u4e0b\u6807&#xff0c;\u5143\u7d20\u5141\u8bb8\u91cd\u590d b) \u5e38\u7528\u65b9\u6cd5 V put(K key,V value) \u5f80 Map \u96c6\u5408\u6dfb\u52a0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/102920.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-09T09:49:02+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/102920.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/102920.html\",\"name\":\"Java \u96c6\u5408\uff1aMap \u63a5\u53e3\u5b8c\u6574\u7b14\u8bb0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-09T09:49:02+00:00\",\"dateModified\":\"2026-09-09T09:49:02+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/102920.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/102920.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/102920.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java \u96c6\u5408\uff1aMap \u63a5\u53e3\u5b8c\u6574\u7b14\u8bb0\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java \u96c6\u5408\uff1aMap \u63a5\u53e3\u5b8c\u6574\u7b14\u8bb0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/102920.html","og_locale":"zh_CN","og_type":"article","og_title":"Java \u96c6\u5408\uff1aMap \u63a5\u53e3\u5b8c\u6574\u7b14\u8bb0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001Map \u96c6\u5408\u4f53\u7cfb Map \u662f Map \u96c6\u5408\u4f53\u7cfb\u7684\u6839\u63a5\u53e3 a) Map \u96c6\u5408\u7279\u70b9 \u952e\u503c\u5bf9\u5b58\u50a8key\u2011value&#xff0c;\u4e00\u4e2a\u952e\u503c\u5bf9\u5c31\u662f Map \u96c6\u5408\u5f53\u4e2d\u7684\u4e00\u4e2a\u5143\u7d20key&#xff08;\u952e&#xff09;&#xff1a;\u65e0\u5e8f\u3001\u65e0\u4e0b\u6807&#xff0c;\u5143\u7d20\u4e0d\u5141\u8bb8\u91cd\u590d&#xff0c;\u5177\u6709\u552f\u4e00\u6027value&#xff08;\u503c&#xff09;&#xff1a;\u65e0\u5e8f\u3001\u65e0\u4e0b\u6807&#xff0c;\u5143\u7d20\u5141\u8bb8\u91cd\u590d b) \u5e38\u7528\u65b9\u6cd5 V put(K key,V value) \u5f80 Map \u96c6\u5408\u6dfb\u52a0","og_url":"https:\/\/www.wsisp.com\/helps\/102920.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-09T09:49:02+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/102920.html","url":"https:\/\/www.wsisp.com\/helps\/102920.html","name":"Java \u96c6\u5408\uff1aMap \u63a5\u53e3\u5b8c\u6574\u7b14\u8bb0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-09T09:49:02+00:00","dateModified":"2026-09-09T09:49:02+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/102920.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/102920.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/102920.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Java \u96c6\u5408\uff1aMap \u63a5\u53e3\u5b8c\u6574\u7b14\u8bb0"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/102920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=102920"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/102920\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=102920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=102920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=102920"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=102920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}