{"id":413,"date":"2022-08-20T22:14:53","date_gmt":"2023-05-28T04:37:31","guid":{"rendered":"https:\/\/www.silicloud.com\/ja\/blog\/index.php\/2023\/11\/30\/java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap\/"},"modified":"2025-07-31T23:24:01","modified_gmt":"2025-07-31T14:24:01","slug":"java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap\/","title":{"rendered":"Java\u306eHashMap &#8211; Java\u306b\u304a\u3051\u308bHashMap"},"content":{"rendered":"<p>Java\u306eHashMap\u306f\u3001Java\u3067\u6700\u3082\u4eba\u6c17\u306e\u3042\u308bCollection\u30af\u30e9\u30b9\u306e\u4e00\u3064\u3067\u3059\u3002Java\u306eHashMap\u306f\u30cf\u30c3\u30b7\u30e5\u30c6\u30fc\u30d6\u30eb\u30d9\u30fc\u30b9\u306e\u5b9f\u88c5\u3067\u3059\u3002Java\u306eHashMap\u306f\u3001Map\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u5b9f\u88c5\u3059\u308bAbstractMap\u30af\u30e9\u30b9\u3092\u62e1\u5f35\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u79c1\u306e\u63d0\u6848\u306f\u3001Java\u306eHashMap\u3067\u3059\u3002<\/h2>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65648c1adaa94e2bdf7bc5e7\/2-0.jpg\" alt=\"java hashmap, hashmap in java, java hashmap example, java hashmap tutorial\" \/><\/div>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>Java\u306eHashMap\u306f\u3001null\u30ad\u30fc\u3068null\u5024\u3092\u8a31\u5bb9\u3057\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>HashMap\u306f\u9806\u5e8f\u4ed8\u3051\u3089\u308c\u305f\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002HashMap\u306e\u30a8\u30f3\u30c8\u30ea\u306b\u306f\u30ad\u30fc\u30bb\u30c3\u30c8\u3092\u901a\u3058\u3066\u53cd\u5fa9\u51e6\u7406\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u30a8\u30f3\u30c8\u30ea\u306e\u9806\u5e8f\u306fHashMap\u3078\u306e\u8ffd\u52a0\u9806\u5e8f\u3092\u4fdd\u8a3c\u3059\u308b\u3082\u306e\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>HashMap\u306f\u3001Hashtable\u3068\u307b\u307c\u540c\u3058\u3067\u3059\u304c\u3001\u975e\u540c\u671f\u3067null\u30ad\u30fc\u3068\u5024\u3092\u8a31\u5bb9\u3057\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>HashMap\u306f\u3001\u30de\u30c3\u30d7\u306e\u30a8\u30f3\u30c8\u30ea\u3092\u683c\u7d0d\u3059\u308b\u305f\u3081\u306b\u5185\u90e8\u30af\u30e9\u30b9\u306eNode&lt;K, V&gt;\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>HashMap\u306f\u3001\u8907\u6570\u306e\u30b7\u30f3\u30b0\u30eb\u30ea\u30f3\u30af\u30ea\u30b9\u30c8\uff08\u30d0\u30b1\u30c3\u30c8\u307e\u305f\u306f\u30d3\u30f3\u3068\u547c\u3070\u308c\u308b\uff09\u306b\u30a8\u30f3\u30c8\u30ea\u3092\u683c\u7d0d\u3057\u307e\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30d0\u30b1\u30c3\u30c8\u6570\u306f16\u3067\u3042\u308a\u3001\u5e38\u306b2\u306e\u7d2f\u4e57\u3067\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>HashMap\u306f\u3001get\u304a\u3088\u3073put\u64cd\u4f5c\u306b\u304a\u3044\u3066\u3001\u30ad\u30fc\u306ehashCode\uff08\uff09\u304a\u3088\u3073equals\uff08\uff09\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u3057\u305f\u304c\u3063\u3066\u3001HashMap\u30ad\u30fc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u3053\u308c\u3089\u306e\u30e1\u30bd\u30c3\u30c9\u306e\u826f\u597d\u306a\u5b9f\u88c5\u3092\u63d0\u4f9b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u304c\u3001\u30ad\u30fc\u306b\u306f\u4e0d\u5909\u30af\u30e9\u30b9\uff08\u4f8b\uff1a\u6587\u5b57\u5217\u3068\u6574\u6570\uff09\u304c\u9069\u3057\u3066\u3044\u308b\u7406\u7531\u3067\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>Java\u306eHashMap\u306f\u30b9\u30ec\u30c3\u30c9\u30bb\u30fc\u30d5\u3067\u306f\u306a\u3044\u305f\u3081\u3001\u30de\u30eb\u30c1\u30b9\u30ec\u30c3\u30c9\u74b0\u5883\u3067\u306fConcurrentHashMap\u30af\u30e9\u30b9\u3092\u4f7f\u7528\u3059\u308b\u304b\u3001Collections.synchronizedMap\uff08\uff09\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u540c\u671f\u5316\u3055\u308c\u305f\u30de\u30c3\u30d7\u3092\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/ol>\n<h3>Java\u306eHashMap\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf<\/h3>\n<p>Java\u306eHashMap\u306b\u306f4\u3064\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u304c\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public HashMap(): \u6700\u3082\u4e00\u822c\u7684\u306b\u4f7f\u7528\u3055\u308c\u308bHashMap\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3067\u3059\u3002\u3053\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u521d\u671f\u5bb9\u91cf16\u3068\u30ed\u30fc\u30c9\u30d5\u30a1\u30af\u30bf\u30fc0.75\u3067\u7a7a\u306eHashMap\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public HashMap(int initialCapacity): \u3053\u306eHashMap\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f\u3001\u521d\u671f\u5bb9\u91cf\u3068\u30ed\u30fc\u30c9\u30d5\u30a1\u30af\u30bf\u30fc0.75\u3092\u6307\u5b9a\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002HashMap\u306b\u683c\u7d0d\u3059\u308b\u30de\u30c3\u30d4\u30f3\u30b0\u306e\u6570\u3092\u4e8b\u524d\u306b\u77e5\u3063\u3066\u3044\u308b\u5834\u5408\u3001\u518d\u30cf\u30c3\u30b7\u30e5\u3092\u56de\u907f\u3059\u308b\u306e\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public HashMap(int initialCapacity, float loadFactor): \u3053\u306eHashMap\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u521d\u671f\u5bb9\u91cf\u3068\u30ed\u30fc\u30c9\u30d5\u30a1\u30af\u30bf\u30fc\u3092\u6301\u3064\u7a7a\u306eHashMap\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002HashMap\u306b\u683c\u7d0d\u3059\u308b\u6700\u5927\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u6570\u3092\u4e8b\u524d\u306b\u77e5\u3063\u3066\u3044\u308b\u5834\u5408\u306b\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4e00\u822c\u7684\u306a\u30b7\u30ca\u30ea\u30aa\u3067\u306f\u3001\u30b9\u30da\u30fc\u30b9\u3068\u6642\u9593\u306e\u30b3\u30b9\u30c8\u306e\u30c8\u30ec\u30fc\u30c9\u30aa\u30d5\u3092\u63d0\u4f9b\u3059\u308b\u30ed\u30fc\u30c9\u30d5\u30a1\u30af\u30bf\u30fc0.75\u3092\u907f\u3051\u308b\u3079\u304d\u3067\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>public HashMap(Map&lt;? extends K, ? extends V&gt; m): \u6307\u5b9a\u3055\u308c\u305f\u30de\u30c3\u30d7\u3068\u30ed\u30fc\u30c9\u30d5\u30a1\u30af\u30bf\u30fc0.75\u3092\u6301\u3064\u540c\u3058\u30de\u30c3\u30d4\u30f3\u30b0\u3092\u6301\u3064\u30de\u30c3\u30d7\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/ol>\n<h3>Java\u306eHashMap\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/h3>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u30b9\u30cb\u30da\u30c3\u30c8\u306f\u3001\u4e0a\u8a18\u306e\u3059\u3079\u3066\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u4f7f\u7528\u3057\u305fHashMap\u306e\u4f8b\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>Map&lt;String, String&gt; map1 = new HashMap&lt;&gt;();\r\n\r\nMap&lt;String, String&gt; map2 = new HashMap&lt;&gt;(2^5);\r\n\r\nMap&lt;String, String&gt; map3 = new HashMap&lt;&gt;(32,0.80f);\r\n\r\nMap&lt;String,String&gt; map4 = new HashMap&lt;&gt;(map1);\r\n<\/code><\/pre>\n<h3>Java\u306eHashMap\u30e1\u30bd\u30c3\u30c9<\/h3>\n<p>Java\u306eHashMap\u306e\u91cd\u8981\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public void clear(): \u3053\u306eHashMap\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u3059\u3079\u3066\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u3092\u524a\u9664\u3057\u3001HashMap\u3092\u7a7a\u306b\u3057\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public boolean containsKey(Object key): \u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u304c\u5b58\u5728\u3059\u308b\u5834\u5408\u306f\u300ctrue\u300d\u3092\u8fd4\u3057\u3001\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f\u300cfalse\u300d\u3092\u8fd4\u3057\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public boolean containsValue(Object value): \u3053\u306eHashMap\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u5024\u304c\u5b58\u5728\u3059\u308b\u5834\u5408\u306f\u300ctrue\u300d\u3092\u8fd4\u3057\u3001\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f\u300cfalse\u300d\u3092\u8fd4\u3057\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public Set&lt;Map.Entry&lt;K,V&gt;&gt; entrySet(): \u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u3001HashMap\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u306eSet\u30d3\u30e5\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002\u3053\u306e\u30bb\u30c3\u30c8\u306f\u3001\u30de\u30c3\u30d7\u306b\u3088\u3063\u3066\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3055\u308c\u308b\u305f\u3081\u3001\u30de\u30c3\u30d7\u306e\u5909\u66f4\u306f\u30bb\u30c3\u30c8\u306b\u53cd\u6620\u3055\u308c\u3001\u9006\u3082\u307e\u305f\u7136\u308a\u3067\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public V get(Object key): \u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3055\u308c\u305f\u5024\u3092\u8fd4\u3057\u307e\u3059\u3002\u30ad\u30fc\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u304c\u306a\u3044\u5834\u5408\u306fnull\u3092\u8fd4\u3057\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public boolean isEmpty(): \u30ad\u30fc\u3068\u5024\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306ftrue\u3092\u8fd4\u3059\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public Set keySet(): \u3053\u306e\u30de\u30c3\u30d7\u306b\u542b\u307e\u308c\u308b\u30ad\u30fc\u306eSet\u30d3\u30e5\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002\u3053\u306e\u30bb\u30c3\u30c8\u306f\u30de\u30c3\u30d7\u306b\u3088\u3063\u3066\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3055\u308c\u308b\u305f\u3081\u3001\u30de\u30c3\u30d7\u306e\u5909\u66f4\u306f\u30bb\u30c3\u30c8\u306b\u53cd\u6620\u3055\u308c\u3001\u9006\u3082\u307e\u305f\u7136\u308a\u3067\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public V put(K key, V value): \u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u306b\u6307\u5b9a\u3055\u308c\u305f\u5024\u3092\u3053\u306e\u30de\u30c3\u30d7\u306b\u95a2\u9023\u4ed8\u3051\u307e\u3059\u3002\u30de\u30c3\u30d7\u304c\u65e2\u306b\u30ad\u30fc\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u3092\u6301\u3063\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u53e4\u3044\u5024\u304c\u7f6e\u304d\u63db\u3048\u3089\u308c\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public void putAll(Map&lt;? extends K, ? extends V&gt; m): \u6307\u5b9a\u3055\u308c\u305f\u30de\u30c3\u30d7\u304b\u3089\u3059\u3079\u3066\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u3092\u3053\u306e\u30de\u30c3\u30d7\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002\u3053\u308c\u3089\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u30de\u30c3\u30d7\u5185\u306e\u73fe\u5728\u306e\u30ad\u30fc\u306e\u3044\u305a\u308c\u304b\u306b\u5bfe\u3057\u3066\u3001\u3053\u306e\u30de\u30c3\u30d7\u304c\u6301\u3063\u3066\u3044\u305f\u4efb\u610f\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u3092\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public V remove(Object key): \u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u306b\u5bfe\u5fdc\u3059\u308b\u30de\u30c3\u30d4\u30f3\u30b0\u3092\u3053\u306e\u30de\u30c3\u30d7\u304b\u3089\u524a\u9664\u3057\u307e\u3059\uff08\u5b58\u5728\u3059\u308b\u5834\u5408\uff09\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public int size(): \u3053\u306e\u30de\u30c3\u30d7\u306e\u30ad\u30fc\u3068\u5024\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u306e\u6570\u3092\u8fd4\u3057\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>public Collection values(): \u3053\u306e\u30de\u30c3\u30d7\u306b\u542b\u307e\u308c\u308b\u5024\u306eCollection\u30d3\u30e5\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002\u3053\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306f\u30de\u30c3\u30d7\u306b\u3088\u3063\u3066\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3055\u308c\u308b\u305f\u3081\u3001\u30de\u30c3\u30d7\u306e\u5909\u66f4\u306f\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306b\u53cd\u6620\u3055\u308c\u3001\u9006\u3082\u307e\u305f\u7136\u308a\u3067\u3059\u3002<\/ol>\n<p>Java 8\u3067\u5c0e\u5165\u3055\u308c\u305fHashMap\u306e\u65b0\u3057\u3044\u30e1\u30bd\u30c3\u30c9\u306f\u305f\u304f\u3055\u3093\u3042\u308a\u307e\u3059\u3002<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>public V computeIfAbsent(K key, Function&lt;? super K, ? extends V&gt; mappingFunction): \u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u304c\u5024\u3068\u95a2\u9023\u4ed8\u3051\u3089\u308c\u3066\u3044\u306a\u3044\u5834\u5408\uff08\u307e\u305f\u306fnull\u306b\u30de\u30c3\u30d7\u3055\u308c\u3066\u3044\u308b\u5834\u5408\uff09\u3001\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u4e0e\u3048\u3089\u308c\u305f\u30de\u30c3\u30d4\u30f3\u30b0\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u305d\u306e\u5024\u3092\u8a08\u7b97\u3057\u3001\u305d\u308c\u3092HashMap\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>public V computeIfPresent(K key, BiFunction&lt;? super K, ? super V, ? extends V&gt; remappingFunction): \u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u306b\u5bfe\u3059\u308b\u5024\u304c\u5b58\u5728\u3057\u3001\u975enull\u3067\u3042\u308b\u5834\u5408\u3001\u73fe\u5728\u306e\u30ad\u30fc\u3068\u305d\u306e\u73fe\u5728\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u3055\u308c\u305f\u5024\u3092\u4f7f\u7528\u3057\u3066\u65b0\u3057\u3044\u30de\u30c3\u30d4\u30f3\u30b0\u3092\u8a08\u7b97\u3057\u3088\u3046\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>public V compute(K key, BiFunction&lt;? super K, ? super V, ? extends V&gt; remappingFunction): \u3053\u306eHashMap\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u3068\u305d\u306e\u73fe\u5728\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u3055\u308c\u305f\u5024\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u3092\u8a08\u7b97\u3057\u3088\u3046\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>public void forEach(BiConsumer&lt;? super K, ? super V&gt; action): \u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u3053\u306e\u30de\u30c3\u30d7\u306e\u5404\u30a8\u30f3\u30c8\u30ea\u306b\u6307\u5b9a\u3055\u308c\u305f\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>public V getOrDefault(Object key, V defaultValue): get\u3068\u540c\u3058\u3067\u3059\u304c\u3001\u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u306b\u5bfe\u3057\u3066\u30de\u30c3\u30d4\u30f3\u30b0\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u306fdefaultValue\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>public V merge(K key, V value, BiFunction&lt;? super V, ? super V, ? extends V&gt; remappingFunction): \u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u304c\u5024\u3068\u95a2\u9023\u4ed8\u3051\u3089\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u3001\u307e\u305f\u306fnull\u306b\u95a2\u9023\u4ed8\u3051\u3089\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u305d\u308c\u3092\u6307\u5b9a\u3055\u308c\u305f\u975enull\u5024\u3067\u95a2\u9023\u4ed8\u3051\u307e\u3059\u3002\u305d\u3046\u3067\u306a\u3044\u5834\u5408\u3001\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\u5024\u3092\u3001\u6307\u5b9a\u3055\u308c\u305f\u30ea\u30de\u30c3\u30d4\u30f3\u30b0\u95a2\u6570\u306e\u7d50\u679c\u3067\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002\u7d50\u679c\u304cnull\u306e\u5834\u5408\u306f\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<p>public V putIfAbsent(K key, V value): \u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u304c\u5024\u3068\u95a2\u9023\u4ed8\u3051\u3089\u308c\u3066\u3044\u306a\u3044\u5834\u5408\uff08\u307e\u305f\u306fnull\u306b\u30de\u30c3\u30d7\u3055\u308c\u3066\u3044\u308b\u5834\u5408\uff09\u3001\u305d\u308c\u3092\u6307\u5b9a\u3055\u308c\u305f\u5024\u3067\u95a2\u9023\u4ed8\u3051\u307e\u3059\u3002null\u304c\u8fd4\u3055\u308c\u3001\u305d\u308c\u4ee5\u5916\u306e\u5834\u5408\u306f\u73fe\u5728\u306e\u5024\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>public boolean remove(Object key, Object value): \u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u306b\u5bfe\u5fdc\u3059\u308b\u30a8\u30f3\u30c8\u30ea\u3092\u6307\u5b9a\u3055\u308c\u305f\u5024\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306b\u306e\u307f\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<p>public boolean replace(K key, V oldValue, V newValue): \u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u306b\u5bfe\u5fdc\u3059\u308b\u30a8\u30f3\u30c8\u30ea\u3092\u3001\u73fe\u5728\u306e\u5024\u304c\u6307\u5b9a\u3055\u308c\u305f\u5024\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306b\u306e\u307f\u7f6e\u63db\u3057\u307e\u3059\u3002<\/p>\n<p>public V replace(K key, V value): \u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u306b\u5bfe\u5fdc\u3059\u308b\u30a8\u30f3\u30c8\u30ea\u3092\u3001\u73fe\u5728\u306e\u5024\u304c\u30de\u30c3\u30d4\u30f3\u30b0\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306b\u306e\u307f\u7f6e\u63db\u3057\u307e\u3059\u3002<\/p>\n<p>public void replaceAll(BiFunction&lt;? super K, ? super V, ? extends V&gt; function): \u5404\u30a8\u30f3\u30c8\u30ea\u306e\u5024\u3092\u3001\u305d\u306e\u30a8\u30f3\u30c8\u30ea\u4e0a\u3067\u6307\u5b9a\u3055\u308c\u305f\u95a2\u6570\u3092\u547c\u3073\u51fa\u3057\u305f\u7d50\u679c\u3067\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<h3>Java\u306eHashMap\u306e\u4f8b<\/h3>\n<p>\u3053\u3061\u3089\u306f\u3001HashMap\u306e\u4e00\u822c\u7684\u306a\u4f7f\u7528\u65b9\u6cd5\u306b\u95a2\u3059\u308b\u30b7\u30f3\u30d7\u30eb\u306aJava\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.examples;\r\n\r\nimport java.util.Collection;\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\nimport java.util.Map.Entry;\r\nimport java.util.Set;\r\n\r\npublic class HashMapExample {\r\n\r\n\tpublic static void main(String[] args) {\r\n\r\n\t\tMap&lt;String, String&gt; map = new HashMap&lt;&gt;();\r\n\r\n\t\tmap.put(\"1\", \"1\"); \/\/ put example\r\n\t\tmap.put(\"2\", \"2\");\r\n\t\tmap.put(\"3\", \"3\");\r\n\t\tmap.put(\"4\", null); \/\/ null value\r\n\t\tmap.put(null, \"100\"); \/\/ null key\r\n\r\n\t\tString value = map.get(\"3\"); \/\/ get example\r\n\t\tSystem.out.println(\"Key = 3, Value = \" + value);\r\n\r\n\t\tvalue = map.getOrDefault(\"5\", \"Default Value\");\r\n\t\tSystem.out.println(\"Key = 5, Value=\" + value);\r\n\r\n\t\tboolean keyExists = map.containsKey(null);\r\n\t\tboolean valueExists = map.containsValue(\"100\");\r\n\r\n\t\tSystem.out.println(\"keyExists=\" + keyExists + \", valueExists=\" + valueExists);\r\n\r\n\t\tSet&lt;Entry&lt;String, String&gt;&gt; entrySet = map.entrySet();\r\n\t\tSystem.out.println(entrySet);\r\n\r\n\t\tSystem.out.println(\"map size=\" + map.size());\r\n\r\n\t\tMap&lt;String, String&gt; map1 = new HashMap&lt;&gt;();\r\n\t\tmap1.putAll(map);\r\n\t\tSystem.out.println(\"map1 mappings= \" + map1);\r\n\r\n\t\tString nullKeyValue = map1.remove(null);\r\n\t\tSystem.out.println(\"map1 null key value = \" + nullKeyValue);\r\n\t\tSystem.out.println(\"map1 after removing null key = \" + map1);\r\n\r\n\t\tSet&lt;String&gt; keySet = map.keySet();\r\n\t\tSystem.out.println(\"map keys = \" + keySet);\r\n\r\n\t\tCollection&lt;String&gt; values = map.values();\r\n\t\tSystem.out.println(\"map values = \" + values);\r\n\r\n\t\tmap.clear();\r\n\t\tSystem.out.println(\"map is empty=\" + map.isEmpty());\r\n\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0b\u306f\u3001\u4e0a\u8a18\u306eJava HashMap\u306e\u4f8b\u984c\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u51fa\u529b\u3067\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>Key = 3, Value = 3\r\nKey = 5, Value=Default Value\r\nkeyExists=true, valueExists=true\r\n[null=100, 1=1, 2=2, 3=3, 4=null]\r\nmap size=5\r\nmap1 mappings= {null=100, 1=1, 2=2, 3=3, 4=null}\r\nmap1 null key value = 100\r\nmap1 after removing null key = {1=1, 2=2, 3=3, 4=null}\r\nmap keys = [null, 1, 2, 3, 4]\r\nmap values = [100, 1, 2, 3, null]\r\nmap is empty=true\r\n<\/code><\/pre>\n<h3>Java\u3067HashMap\u306f\u3069\u306e\u3088\u3046\u306b\u52d5\u4f5c\u3057\u307e\u3059\u304b\uff1f<\/h3>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65648c1adaa94e2bdf7bc5e7\/21-0.png\" alt=\"java hashmap internal implementation, how hashmap works in java\" \/><\/div>\n<h3>Java\u306eHashMap\u306e\u30ed\u30fc\u30c9\u30d5\u30a1\u30af\u30bf\u30fc\u3092\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/h3>\n<p>\u30ed\u30fc\u30c9\u30d5\u30a1\u30af\u30bf\u30fc\u306f\u3001HashMap\u304c\u30ea\u30cf\u30c3\u30b7\u30e5\u3055\u308c\u3001\u30d0\u30b1\u30c3\u30c8\u306e\u30b5\u30a4\u30ba\u304c\u5897\u52a0\u3059\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u3092\u8a08\u7b97\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u30d0\u30b1\u30c3\u30c8\u307e\u305f\u306f\u30ad\u30e3\u30d1\u30b7\u30c6\u30a3\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306f16\u3067\u3001\u30ed\u30fc\u30c9\u30d5\u30a1\u30af\u30bf\u30fc\u306f0.75\u3067\u3059\u3002\u30ea\u30cf\u30c3\u30b7\u30e5\u306e\u3057\u304d\u3044\u5024\u306f\u3001\u30ad\u30e3\u30d1\u30b7\u30c6\u30a3\u3068\u30ed\u30fc\u30c9\u30d5\u30a1\u30af\u30bf\u30fc\u3092\u4e57\u7b97\u3057\u3066\u8a08\u7b97\u3055\u308c\u307e\u3059\u3002\u3057\u305f\u304c\u3063\u3066\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u3057\u304d\u3044\u5024\u306f12\u306b\u306a\u308a\u307e\u3059\u3002\u3064\u307e\u308a\u3001HashMap\u306b12\u4ee5\u4e0a\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u304c\u3042\u308b\u3068\u3001\u30ea\u30cf\u30c3\u30b7\u30e5\u304c\u884c\u308f\u308c\u3001\u30d3\u30f3\u306e\u6570\u304c2\u306e\u3079\u304d\u4e57\u3067\u3042\u308b32\u306b\u5897\u52a0\u3057\u307e\u3059\u3002HashMap\u306e\u30ad\u30e3\u30d1\u30b7\u30c6\u30a3\u306f\u5e38\u306b2\u306e\u3079\u304d\u4e57\u3067\u3042\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30ed\u30fc\u30c9\u30d5\u30a1\u30af\u30bf\u30fc0.75\u306f\u3001\u30b9\u30da\u30fc\u30b9\u3068\u6642\u9593\u306e\u8907\u96d1\u3055\u306e\u30c8\u30ec\u30fc\u30c9\u30aa\u30d5\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u7570\u306a\u308b\u5024\u306b\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u30b9\u30da\u30fc\u30b9\u3092\u7bc0\u7d04\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u5024\u30920.80\u307e\u305f\u306f0.90\u306b\u5897\u3084\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u305d\u306e\u5834\u5408\u3001get \/ put\u64cd\u4f5c\u306b\u306f\u3088\u308a\u591a\u304f\u306e\u6642\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u3002<\/p>\n<h3>Java \u306e HashMap \u306e keySet<\/h3>\n<p>Java\u306eHashMap\u306ekeySet\u30e1\u30bd\u30c3\u30c9\u306f\u3001HashMap\u5185\u306e\u30ad\u30fc\u306eSet\u30d3\u30e5\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002\u3053\u306eSet\u30d3\u30e5\u30fc\u306fHashMap\u306b\u3088\u3063\u3066\u652f\u3048\u3089\u308c\u3066\u304a\u308a\u3001HashMap\u306e\u5909\u66f4\u306fSet\u306b\u53cd\u6620\u3055\u308c\u3001\u9006\u3082\u307e\u305f\u7136\u308a\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u306f\u3001HashMap\u306ekeySet\u306e\u4f8b\u3092\u793a\u3059\u7c21\u5358\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3068\u3001\u30de\u30c3\u30d7\u306b\u3088\u3063\u3066\u652f\u3048\u3089\u308c\u3066\u3044\u306a\u3044keySet\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.examples;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.HashSet;\r\nimport java.util.Map;\r\nimport java.util.Set;\r\n\r\npublic class HashMapKeySetExample {\r\n\r\n\tpublic static void main(String[] args) {\r\n\r\n\t\tMap&lt;String, String&gt; map = new HashMap&lt;&gt;();\r\n\t\tmap.put(\"1\", \"1\");\r\n\t\tmap.put(\"2\", \"2\");\r\n\t\tmap.put(\"3\", \"3\");\r\n\r\n\t\tSet&lt;String&gt; keySet = map.keySet();\r\n\t\tSystem.out.println(keySet);\r\n\r\n\t\tmap.put(\"4\", \"4\");\r\n\t\tSystem.out.println(keySet); \/\/ keySet is backed by Map\r\n\r\n\t\tkeySet.remove(\"1\");\r\n\t\tSystem.out.println(map); \/\/ map is also modified\r\n\r\n\t\tkeySet = new HashSet&lt;&gt;(map.keySet()); \/\/ copies the key to new Set\r\n\t\tmap.put(\"5\", \"5\");\r\n\t\tSystem.out.println(keySet); \/\/ keySet is not modified\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u51fa\u529b\u7d50\u679c\u304b\u3089\u3001keySet\u304cmap\u306b\u3088\u3063\u3066\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u660e\u78ba\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>[1, 2, 3]\r\n[1, 2, 3, 4]\r\n{2=2, 3=3, 4=4}\r\n[2, 3, 4]\r\n<\/code><\/pre>\n<h3>Java \u306e HashMap \u306e\u5024<\/h3>\n<p>Java\u306eHashMap\u306evalues\u30e1\u30bd\u30c3\u30c9\u306f\u3001Map\u5185\u306e\u5024\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30d3\u30e5\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002\u3053\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306fHashMap\u3067\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001HashMap\u306e\u5909\u66f4\u306f\u5024\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306b\u53cd\u6620\u3055\u308c\u3001\u9006\u3082\u307e\u305f\u7136\u308a\u3067\u3059\u3002\u4ee5\u4e0b\u306e\u7c21\u5358\u306a\u4f8b\u306f\u3001HashMap\u306e\u5024\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u3053\u306e\u6319\u52d5\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.examples;\r\n\r\nimport java.util.Collection;\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\n\r\npublic class HashMapValuesExample {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tMap&lt;String, String&gt; map = new HashMap&lt;&gt;();\r\n\t\tmap.put(\"1\", \"1\");\r\n\t\tmap.put(\"2\", \"2\");\r\n\t\tmap.put(\"3\", null);\r\n\t\tmap.put(\"4\", null);\r\n\t\tmap.put(null, \"100\");\r\n\r\n\t\tCollection&lt;String&gt; values = map.values();\r\n\t\tSystem.out.println(\"map values = \" + values);\r\n\r\n\t\tmap.remove(null);\r\n\t\tSystem.out.println(\"map values after removing null key = \" + values);\r\n\r\n\t\tmap.put(\"5\", \"5\");\r\n\t\tSystem.out.println(\"map values after put = \" + values);\r\n\r\n\t\tSystem.out.println(map);\r\n\t\tvalues.remove(\"1\"); \/\/ changing values collection\r\n\t\tSystem.out.println(map); \/\/ updates in map too\r\n\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u51fa\u529b\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>map values = [100, 1, 2, null, null]\r\nmap values after removing null key = [1, 2, null, null]\r\nmap values after put = [1, 2, null, null, 5]\r\n{1=1, 2=2, 3=null, 4=null, 5=5}\r\n{2=2, 3=null, 4=null, 5=5}\r\n<\/code><\/pre>\n<h3>Java\u306eHashMap\u306eentrySet<\/h3>\n<p>Java\u306eHashMap\u306eentrySet\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30de\u30c3\u30d4\u30f3\u30b0\u306eSet\u30d3\u30e5\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002\u3053\u306eentrySet\u306fHashMap\u306b\u3088\u3063\u3066\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001\u30de\u30c3\u30d7\u306e\u5909\u66f4\u306f\u30a8\u30f3\u30c8\u30ea\u30fc\u30bb\u30c3\u30c8\u306b\u53cd\u6620\u3055\u308c\u3001\u9006\u3082\u540c\u69d8\u3067\u3059\u3002\u4ee5\u4e0b\u306eHashMap\u306eentrySet\u306e\u4f8b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.examples;\r\n\r\nimport java.util.AbstractMap;\r\nimport java.util.HashMap;\r\nimport java.util.Iterator;\r\nimport java.util.Map;\r\nimport java.util.Map.Entry;\r\nimport java.util.Set;\r\n\r\npublic class HashMapEntrySetExample {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tMap&lt;String, String&gt; map = new HashMap&lt;&gt;();\r\n\t\tmap.put(\"1\", \"1\");\r\n\t\tmap.put(\"2\", null);\r\n\t\tmap.put(null, \"100\");\r\n\r\n\t\tSet&lt;Entry&lt;String,String&gt;&gt; entrySet = map.entrySet();\r\n\t\tIterator&lt;Entry&lt;String, String&gt;&gt; iterator = entrySet.iterator();\r\n\t\tEntry&lt;String, String&gt; next = null;\r\n\t\t\r\n\t\tSystem.out.println(\"map before processing = \"+map);\r\n\t\tSystem.out.println(\"entrySet before processing = \"+entrySet);\r\n\t\twhile(iterator.hasNext()){\r\n\t\t\tnext = iterator.next();\r\n\t\t\tSystem.out.println(\"Processing on: \"+next.getValue());\r\n\t\t\tif(next.getKey() == null) iterator.remove();\r\n\t\t}\r\n\t\t\r\n\t\tSystem.out.println(\"map after processing = \"+map);\r\n\t\tSystem.out.println(\"entrySet after processing = \"+entrySet);\r\n\t\t\r\n\t\tEntry&lt;String, String&gt; simpleEntry = new AbstractMap.SimpleEntry&lt;String, String&gt;(\"1\",\"1\");\r\n\t\tentrySet.remove(simpleEntry);\r\n\t\tSystem.out.println(\"map after removing Entry = \"+map);\r\n\t\tSystem.out.println(\"entrySet after removing Entry = \"+entrySet);\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u3088\u3063\u3066\u751f\u6210\u3055\u308c\u305f\u51fa\u529b\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>map before processing = {null=100, 1=1, 2=null}\r\nentrySet before processing = [null=100, 1=1, 2=null]\r\nProcessing on: 100\r\nProcessing on: 1\r\nProcessing on: null\r\nmap after processing = {1=1, 2=null}\r\nentrySet after processing = [1=1, 2=null]\r\nmap after removing Entry = {2=null}\r\nentrySet after removing Entry = [2=null]\r\n<\/code><\/pre>\n<h3>Java\u306eHashMap\u306eputIfAbsent<\/h3>\n<p>Java 8\u3067\u5c0e\u5165\u3055\u308c\u305fHashMap\u306eputIfAbsent\u30e1\u30bd\u30c3\u30c9\u306e\u30b7\u30f3\u30d7\u30eb\u306a\u4f8b\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.examples;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\n\r\npublic class HashMapPutIfAbsentExample {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tMap&lt;String, String&gt; map = new HashMap&lt;&gt;();\r\n\t\tmap.put(\"1\", \"1\");\r\n\t\tmap.put(\"2\", null);\r\n\t\tmap.put(null, \"100\");\r\n\r\n\t\tSystem.out.println(\"map before putIfAbsent = \"+map);\r\n\t\tString value = map.putIfAbsent(\"1\", \"4\");\r\n\t\tSystem.out.println(\"map after putIfAbsent = \"+map);\r\n\t\tSystem.out.println(\"putIfAbsent returns: \"+value);\r\n\t\t\r\n\t\tSystem.out.println(\"map before putIfAbsent = \"+map);\r\n\t\tvalue = map.putIfAbsent(\"3\", \"3\");\r\n\t\tSystem.out.println(\"map after putIfAbsent = \"+map);\r\n\t\tSystem.out.println(\"putIfAbsent returns: \"+value);\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u51fa\u529b\u306f\u3001-<\/p>\n<pre class=\"post-pre\"><code>map before putIfAbsent = {null=100, 1=1, 2=null}\r\nmap after putIfAbsent = {null=100, 1=1, 2=null}\r\nputIfAbsent returns: 1\r\nmap before putIfAbsent = {null=100, 1=1, 2=null}\r\nmap after putIfAbsent = {null=100, 1=1, 2=null, 3=3}\r\nputIfAbsent returns: null\r\n<\/code><\/pre>\n<h3>Java\u306eHashMap\u306eforEach\u30e1\u30bd\u30c3\u30c9\u3092\u8a00\u8449\u3092\u5909\u3048\u305a\u306b\u65e5\u672c\u8a9e\u3067\u8868\u73fe\u3059\u308b\u3068\u3001 &#8220;`Java HashMap\u306eforEach&#8220;` \u3067\u3059\u3002<\/h3>\n<p>Java 8\u3067\u5c0e\u5165\u3055\u308c\u305fHashMap\u306eforEach\u30e1\u30bd\u30c3\u30c9\u306f\u975e\u5e38\u306b\u4fbf\u5229\u306a\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u4e0e\u3048\u3089\u308c\u305f\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u3001\u3059\u3079\u3066\u306e\u30a8\u30f3\u30c8\u30ea\u304c\u51e6\u7406\u3055\u308c\u308b\u304b\u3001\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u4f8b\u5916\u3092\u30b9\u30ed\u30fc\u3059\u308b\u307e\u3067\u3001\u30de\u30c3\u30d7\u5185\u306e\u5404\u30a8\u30f3\u30c8\u30ea\u306b\u5bfe\u3057\u3066\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.examples;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\nimport java.util.function.BiConsumer;\r\n\r\npublic class HashMapForEachExample {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tMap&lt;String, String&gt; map = new HashMap&lt;&gt;();\r\n\t\tmap.put(\"1\", \"1\");\r\n\t\tmap.put(\"2\", null);\r\n\t\tmap.put(null, \"100\");\r\n\r\n\t\tBiConsumer&lt;String, String&gt; action = new MyBiConsumer();\r\n\t\tmap.forEach(action);\r\n\t\t\r\n\t\t\/\/lambda expression example\r\n\t\tSystem.out.println(\"\\nHashMap forEach lambda example\\n\");\r\n\t\tmap.forEach((k,v) -&gt; {System.out.println(\"Key = \"+k+\", Value = \"+v);});\r\n\t}\r\n\r\n}\r\n\r\nclass MyBiConsumer implements BiConsumer&lt;String, String&gt; {\r\n\r\n\t@Override\r\n\tpublic void accept(String t, String u) {\r\n\t\tSystem.out.println(\"Key = \" + t);\r\n\t\tSystem.out.println(\"Processing on value = \" + u);\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u306eHashMap\u306eforEach\u306e\u4f8b\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u51fa\u529b\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>Key = null\r\nProcessing on value = 100\r\nKey = 1\r\nProcessing on value = 1\r\nKey = 2\r\nProcessing on value = null\r\n\r\nHashMap forEach lambda example\r\n\r\nKey = null, Value = 100\r\nKey = 1, Value = 1\r\nKey = 2, Value = null\r\n<\/code><\/pre>\n<h3>Java\u306eHashMap\u306ereplaceAll\u30e1\u30bd\u30c3\u30c9\u3092\u65e5\u672c\u8a9e\u3067\u540c\u7fa9\u306e\u8868\u73fe\u3067\u8ff0\u3079\u308b\u3068\u3001\u300cJava\u306eHashMap\u306ereplaceAll\u30e1\u30bd\u30c3\u30c9\u306f\u300d\u3067\u3059\u3002<\/h3>\n<p>HashMap\u306ereplaceAll\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u4e0e\u3048\u3089\u308c\u305f\u95a2\u6570\u3092\u30a8\u30f3\u30c8\u30ea\u3054\u3068\u306b\u547c\u3073\u51fa\u3057\u305f\u7d50\u679c\u3067\u30a8\u30f3\u30c8\u30ea\u306e\u5024\u3092\u7f6e\u304d\u63db\u3048\u308b\u305f\u3081\u306b\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306fJava 8\u3067\u8ffd\u52a0\u3055\u308c\u3001\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306e\u5f15\u6570\u306b\u306f\u30e9\u30e0\u30c0\u5f0f\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.examples;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\nimport java.util.function.BiFunction;\r\n\r\npublic class HashMapReplaceAllExample {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tMap&lt;String, String&gt; map = new HashMap&lt;&gt;();\r\n\t\tmap.put(\"1\", \"1\");\r\n\t\tmap.put(\"2\", \"2\");\r\n\t\tmap.put(null, \"100\");\r\n\r\n\t\tSystem.out.println(\"map before replaceAll = \" + map);\r\n\t\tBiFunction&lt;String, String, String&gt; function = new MyBiFunction();\r\n\t\tmap.replaceAll(function);\r\n\t\tSystem.out.println(\"map after replaceAll = \" + map);\r\n\r\n\t\t\/\/ replaceAll using lambda expressions\r\n\t\tmap.replaceAll((k, v) -&gt; {\r\n\t\t\tif (k != null) return k + v;\r\n\t\t\telse return v;});\r\n\t\tSystem.out.println(\"map after replaceAll lambda expression = \" + map);\r\n\r\n\t}\r\n\r\n}\r\n\r\nclass MyBiFunction implements BiFunction&lt;String, String, String&gt; {\r\n\r\n\t@Override\r\n\tpublic String apply(String t, String u) {\r\n\t\tif (t != null)\r\n\t\t\treturn t + u;\r\n\t\telse\r\n\t\t\treturn u;\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u306eHashMap\u306ereplaceAll\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u51fa\u529b\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>map before replaceAll = {null=100, 1=1, 2=2}\r\nmap after replaceAll = {null=100, 1=11, 2=22}\r\nmap after replaceAll lambda example = {null=100, 1=111, 2=222}\r\n<\/code><\/pre>\n<h3>Java\u306eHashMap\u306ecomputeIfAbsent<\/h3>\n<p>HashMap\u306ecomputeIfAbsent\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30ad\u30fc\u304c\u30de\u30c3\u30d7\u306b\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306b\u306e\u307f\u5024\u3092\u8a08\u7b97\u3057\u307e\u3059\u3002\u5024\u3092\u8a08\u7b97\u3057\u305f\u5f8c\u3001\u305d\u308c\u304cnull\u3067\u306a\u3044\u5834\u5408\u306b\u30de\u30c3\u30d7\u306b\u5165\u308c\u3089\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.examples;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\nimport java.util.function.Function;\r\n\r\npublic class HashMapComputeIfAbsent {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tMap&lt;String, String&gt; map = new HashMap&lt;&gt;();\r\n\t\tmap.put(\"1\", \"10\");\r\n\t\tmap.put(\"2\", \"20\");\r\n\t\tmap.put(null, \"100\");\r\n\r\n\t\tFunction&lt;String, String&gt; function = new MyFunction();\r\n\t\tmap.computeIfAbsent(\"3\", function); \/\/key not present\r\n\t\tmap.computeIfAbsent(\"2\", function); \/\/key already present\r\n\t\t\r\n\t\t\/\/lambda way\r\n\t\tmap.computeIfAbsent(\"4\", v -&gt; {return v;});\r\n\t\tmap.computeIfAbsent(\"5\", v -&gt; {return null;}); \/\/null value won't get inserted\r\n\t\tSystem.out.println(map);\r\n\t}\r\n\r\n}\r\n\r\nclass MyFunction implements Function&lt;String, String&gt; {\r\n\r\n\t@Override\r\n\tpublic String apply(String t) {\r\n\t\treturn t;\r\n\t}\r\n\t\r\n}\r\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u51fa\u529b\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>{null=100, 1=10, 2=20, 3=3, 4=4}\r\n<\/code><\/pre>\n<h3>Java\u306eHashMap\u306ecomputeIfPresent<\/h3>\n<p>Java HashMap\u306ecomputeIfPresent\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u304c\u5b58\u5728\u3057\u3001\u5024\u304cnull\u3067\u306f\u306a\u3044\u5834\u5408\u306b\u3001\u5024\u3092\u518d\u8a08\u7b97\u3057\u307e\u3059\u3002\u3082\u3057\u95a2\u6570\u304cnull\u3092\u8fd4\u3059\u5834\u5408\u3001\u30de\u30c3\u30d4\u30f3\u30b0\u306f\u524a\u9664\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.examples;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\nimport java.util.function.BiFunction;\r\n\r\npublic class HashMapComputeIfPresentExample {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tMap&lt;String, String&gt; map = new HashMap&lt;&gt;();\r\n\t\tmap.put(\"1\", \"10\");\r\n\t\tmap.put(\"2\", \"20\");\r\n\t\tmap.put(null, \"100\");\r\n\t\tmap.put(\"10\", null);\r\n\r\n\t\tSystem.out.println(\"map before computeIfPresent = \" + map);\r\n\t\tBiFunction&lt;String, String, String&gt; function = new MyBiFunction1();\r\n\t\tfor (String key : map.keySet()) {\r\n\t\t\tmap.computeIfPresent(key, function);\r\n\t\t}\r\n\t\t\r\n\t\tSystem.out.println(\"map after computeIfPresent = \" + map);\r\n\t\tmap.computeIfPresent(\"1\", (k,v) -&gt; {return null;}); \/\/ mapping will be removed\r\n\t\tSystem.out.println(\"map after computeIfPresent = \" + map);\r\n\r\n\t}\r\n\r\n}\r\n\r\nclass MyBiFunction1 implements BiFunction&lt;String, String, String&gt; {\r\n\r\n\t@Override\r\n\tpublic String apply(String t, String u) {\r\n\t\treturn t + u;\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<p>HashMap\u306ecomputeIfPresent\u306e\u4f8b\u306b\u3088\u3063\u3066\u751f\u6210\u3055\u308c\u308b\u51fa\u529b\u306f\u3001\u6b21\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>map before computeIfPresent = {null=100, 1=10, 2=20, 10=null}\r\nmap after computeIfPresent = {null=null100, 1=110, 2=220, 10=null}\r\nmap after computeIfPresent = {null=null100, 2=220, 10=null}\r\n<\/code><\/pre>\n<h3>Java\u306eHashMap\u306ecompute\u30e1\u30bd\u30c3\u30c9\u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u308b\u3068\u3001\u4e00\u3064\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u300cJava\u306eHashMap\u306ecompute\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u300d\u3068\u306a\u308a\u307e\u3059\u3002<\/h3>\n<p>\u3082\u3057\u3001\u30ad\u30fc\u3068\u5024\u306b\u57fa\u3065\u3044\u3066\u5168\u3066\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u306b\u95a2\u6570\u3092\u9069\u7528\u3057\u305f\u3044\u5834\u5408\u306f\u3001compute\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3082\u3057\u30de\u30c3\u30d4\u30f3\u30b0\u304c\u5b58\u5728\u305b\u305a\u306b\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u4f7f\u7528\u3055\u308c\u305f\u5834\u5408\u3001compute\u95a2\u6570\u306e\u5024\u306fnull\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.examples;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\n\r\npublic class HashMapComputeExample {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tMap&lt;String, String&gt; map = new HashMap&lt;&gt;();\r\n\t\tmap.put(\"1\", \"1\");\r\n\t\tmap.put(\"2\", \"2\");\r\n\t\tmap.put(null, \"10\");\r\n\t\tmap.put(\"10\", null);\r\n\r\n\t\tSystem.out.println(\"map before compute = \"+map);\r\n\t\tfor (String key : map.keySet()) {\r\n\t\t\tmap.compute(key, (k,v) -&gt; {return k+v;});\r\n\t\t}\r\n\t\tmap.compute(\"5\", (k,v) -&gt; {return k+v;}); \/\/key not present, v = null\r\n\t\tSystem.out.println(\"map after compute = \"+map);\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<p>HashMap\u306ecompute\u306e\u4f8b\u306e\u51fa\u529b\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>map before compute = {null=10, 1=1, 2=2, 10=null}\r\nmap after compute = {null=null10, 1=11, 2=22, 5=5null, 10=10null}\r\n<\/code><\/pre>\n<h3>Java\u306eHashMap\u306e\u30de\u30fc\u30b8<\/h3>\n<p>\u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u304c\u5b58\u5728\u3057\u306a\u3044\u304b\u3001null\u3068\u95a2\u9023\u4ed8\u3051\u3089\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u4e0e\u3048\u3089\u308c\u305f\u975enull\u306e\u5024\u3067\u95a2\u9023\u4ed8\u3051\u307e\u3059\u3002\u305d\u308c\u4ee5\u5916\u306e\u5834\u5408\u306f\u3001\u4e0e\u3048\u3089\u308c\u305f\u30ea\u30de\u30c3\u30d4\u30f3\u30b0\u95a2\u6570\u306e\u7d50\u679c\u3067\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\u5024\u3092\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002\u7d50\u679c\u304cnull\u306e\u5834\u5408\u306f\u3001\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.examples;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\nimport java.util.Map.Entry;\r\n\r\npublic class HashMapMergeExample {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tMap&lt;String, String&gt; map = new HashMap&lt;&gt;();\r\n\t\tmap.put(\"1\", \"1\");\r\n\t\tmap.put(\"2\", \"2\");\r\n\t\tmap.put(null, \"10\");\r\n\t\tmap.put(\"10\", null);\r\n\r\n\t\tfor (Entry&lt;String, String&gt; entry : map.entrySet()) {\r\n\t\t\tString key = entry.getKey();\r\n\t\t\tString value = entry.getValue();\r\n\t\t\t\/\/merge throws NullPointerException if key or value is null\r\n\t\t\tif(key != null &amp;&amp; value != null) \r\n\t\t\tmap.merge(entry.getKey(), entry.getValue(), \r\n\t\t\t\t\t(k, v) -&gt; {return k + v;});\r\n\t\t}\r\n\t\tSystem.out.println(map);\r\n\t\t\r\n\t\tmap.merge(\"5\", \"5\", (k, v) -&gt; {return k + v;}); \/\/ key not present\r\n\t\tSystem.out.println(map);\r\n\t\t\r\n\t\tmap.merge(\"1\", \"1\", (k, v) -&gt; {return null;}); \/\/ method return null, so remove\r\n\t\tSystem.out.println(map);\r\n\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u51fa\u529b\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>{null=10, 1=11, 2=22, 10=null}\r\n{null=10, 1=11, 2=22, 5=5, 10=null}\r\n{null=10, 2=22, 5=5, 10=null}\r\n<\/code><\/pre>\n<p>\u3053\u308c\u3067Java\u306eHashMap\u306b\u3064\u3044\u3066\u306f\u4ee5\u4e0a\u3067\u3059\u3002\u5927\u4e8b\u306a\u70b9\u3092\u898b\u843d\u3068\u3057\u3066\u3044\u306a\u3044\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059\u3002\u3082\u3057\u6c17\u306b\u5165\u3063\u305f\u306a\u3089\u3001\u4ed6\u306e\u4eba\u3068\u3082\u5171\u6709\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u53c2\u8003\uff1aAPI\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java\u306eHashMap\u306f\u3001Java\u3067\u6700\u3082\u4eba\u6c17\u306e\u3042\u308bCollection\u30af\u30e9\u30b9\u306e\u4e00\u3064\u3067\u3059\u3002Java\u306eHashMap\u306f\u30cf\u30c3\u30b7\u30e5\u30c6\u30fc\u30d6\u30eb\u30d9\u30fc\u30b9\u306e\u5b9f\u88c5\u3067\u3059\u3002Java\u306eHashMap\u306f\u3001Map\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u5b9f\u88c5\u3059\u308bAbstr [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[26,61],"class_list":["post-413","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-26","tag-61"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java\u306eHashMap - Java\u306b\u304a\u3051\u308bHashMap - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"Java\u306eHashMap - Java\u306b\u304a\u3051\u308bHashMap\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\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.silicloud.com\/ja\/blog\/java\u306ehashmap-java\u306b\u304a\u3051\u308bhashmap\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java\u306eHashMap - Java\u306b\u304a\u3051\u308bHashMap\" \/>\n<meta property=\"og:description\" content=\"Java\u306eHashMap - Java\u306b\u304a\u3051\u308bHashMap\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/ja\/blog\/java\u306ehashmap-java\u306b\u304a\u3051\u308bhashmap\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-28T04:37:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-31T14:24:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65648c1adaa94e2bdf7bc5e7\/2-0.jpg\" \/>\n<meta name=\"author\" content=\"\u84ee, \u7ffc\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u84ee, \u7ffc\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"42\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap\/\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap\/\",\"name\":\"Java\u306eHashMap - Java\u306b\u304a\u3051\u308bHashMap - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\"},\"datePublished\":\"2023-05-28T04:37:31+00:00\",\"dateModified\":\"2025-07-31T14:24:01+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cdc124a0aaebf26393d8d591183ca413\"},\"description\":\"Java\u306eHashMap - Java\u306b\u304a\u3051\u308bHashMap\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/ja\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\u306eHashMap &#8211; Java\u306b\u304a\u3051\u308bHashMap\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"ja\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cdc124a0aaebf26393d8d591183ca413\",\"name\":\"\u84ee, \u7ffc\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/27308f733c7fcdac8617926a0100c77213339c4e501310a08c0baf946bf823bc?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/27308f733c7fcdac8617926a0100c77213339c4e501310a08c0baf946bf823bc?s=96&d=mm&r=g\",\"caption\":\"\u84ee, \u7ffc\"},\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/author\/rentsubasa\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Java\u306eHashMap - Java\u306b\u304a\u3051\u308bHashMap - Blog - Silicon Cloud","description":"Java\u306eHashMap - Java\u306b\u304a\u3051\u308bHashMap\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","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.silicloud.com\/ja\/blog\/java\u306ehashmap-java\u306b\u304a\u3051\u308bhashmap\/","og_locale":"ja_JP","og_type":"article","og_title":"Java\u306eHashMap - Java\u306b\u304a\u3051\u308bHashMap","og_description":"Java\u306eHashMap - Java\u306b\u304a\u3051\u308bHashMap\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","og_url":"https:\/\/www.silicloud.com\/ja\/blog\/java\u306ehashmap-java\u306b\u304a\u3051\u308bhashmap\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-05-28T04:37:31+00:00","article_modified_time":"2025-07-31T14:24:01+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65648c1adaa94e2bdf7bc5e7\/2-0.jpg"}],"author":"\u84ee, \u7ffc","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u84ee, \u7ffc","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"42\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap\/","url":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap\/","name":"Java\u306eHashMap - Java\u306b\u304a\u3051\u308bHashMap - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website"},"datePublished":"2023-05-28T04:37:31+00:00","dateModified":"2025-07-31T14:24:01+00:00","author":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cdc124a0aaebf26393d8d591183ca413"},"description":"Java\u306eHashMap - Java\u306b\u304a\u3051\u308bHashMap\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/ja\/blog\/"},{"@type":"ListItem","position":2,"name":"Java\u306eHashMap &#8211; Java\u306b\u304a\u3051\u308bHashMap"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website","url":"https:\/\/www.silicloud.com\/ja\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"ja"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cdc124a0aaebf26393d8d591183ca413","name":"\u84ee, \u7ffc","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/27308f733c7fcdac8617926a0100c77213339c4e501310a08c0baf946bf823bc?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/27308f733c7fcdac8617926a0100c77213339c4e501310a08c0baf946bf823bc?s=96&d=mm&r=g","caption":"\u84ee, \u7ffc"},"url":"https:\/\/www.silicloud.com\/ja\/blog\/author\/rentsubasa\/"},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aehashmap-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8bhashmap\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/comments?post=413"}],"version-history":[{"count":1,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/413\/revisions"}],"predecessor-version":[{"id":40283,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/413\/revisions\/40283"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/media?parent=413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/categories?post=413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/tags?post=413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}