{"id":819,"date":"2022-11-17T12:50:02","date_gmt":"2023-01-06T00:45:29","guid":{"rendered":"https:\/\/www.silicloud.com\/ja\/blog\/index.php\/2023\/11\/30\/java%e3%81%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82\/"},"modified":"2025-08-01T02:44:44","modified_gmt":"2025-07-31T17:44:44","slug":"java%e3%81%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82\/","title":{"rendered":"Java\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\u3002"},"content":{"rendered":"<p>Java\u306eequals()\u30e1\u30bd\u30c3\u30c9\u3068hashCode()\u30e1\u30bd\u30c3\u30c9\u306f\u3001Object\u30af\u30e9\u30b9\u306b\u5b58\u5728\u3057\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u3059\u3079\u3066\u306eJava\u30af\u30e9\u30b9\u306f\u3001equals()\u304a\u3088\u3073hashCode()\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u5b9f\u88c5\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u3053\u306e\u6295\u7a3f\u3067\u306f\u3001Java\u306eequals()\u30e1\u30bd\u30c3\u30c9\u3068hashCode()\u30e1\u30bd\u30c3\u30c9\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u898b\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2>Java \u306e equals() \u30e1\u30bd\u30c3\u30c9\u306f\u301c\u3068\u540c\u3058\u3067\u3059\u3002<\/h2>\n<p>\u4ee5\u4e0b\u306e\u901a\u308a\u3001equals()\u30e1\u30bd\u30c3\u30c9\u304c\u5b9a\u7fa9\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30af\u30e9\u30b9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>public boolean equals(Object obj) {\r\n        return (this == obj);\r\n}\r\n<\/code><\/pre>\n<p>Java\u306eequals()\u30e1\u30bd\u30c3\u30c9\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u3088\u308c\u3070\u3001\u5b9f\u88c5\u306f\u4ee5\u4e0b\u306e\u539f\u5247\u306b\u5f93\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul class=\"post-ul\">\n<li>For any object x, x.equals(x) should return true.<\/li>\n<li>For any two object x and y, x.equals(y) should return true if and only if y.equals(x) returns true.<\/li>\n<li>For multiple objects x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.<\/li>\n<li>Multiple invocations of x.equals(y) should return same result, unless any of the object properties is modified that is being used in the equals() method implementation.<\/li>\n<li>Object class equals() method implementation returns true only when both the references are pointing to same object.<\/li>\n<\/ul>\n<h2>Java\u306ehashCode()\u30e1\u30bd\u30c3\u30c9\u3092\u65e5\u672c\u8a9e\u3067\u8a00\u3044\u63db\u3048\u308b\u3068: &#8220;\u30b8\u30e3\u30f4\u30a1\u306e\u30cf\u30c3\u30b7\u30e5\u30b3\u30fc\u30c9()&#8221;<\/h2>\n<p>Java\u306eObject\u30af\u30e9\u30b9\u306ehashCode()\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u6574\u6570\u30cf\u30c3\u30b7\u30e5\u30b3\u30fc\u30c9\u5024\u3092\u8fd4\u3059\u30cd\u30a4\u30c6\u30a3\u30d6\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002hashCode()\u30e1\u30bd\u30c3\u30c9\u306e\u4e00\u822c\u5951\u7d04\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<ul class=\"post-ul\">\n<li>Multiple invocations of hashCode() should return the same integer value, unless the object property is modified that is being used in the equals() method.<\/li>\n<li>An object hash code value can change in multiple executions of the same application.<\/li>\n<li>If two objects are equal according to equals() method, then their hash code must be same.<\/li>\n<li>If two objects are unequal according to equals() method, their hash code are not required to be different. Their hash code value may or may-not be equal.<\/li>\n<\/ul>\n<h2>equals()\u30e1\u30bd\u30c3\u30c9\u3068hashCode()\u30e1\u30bd\u30c3\u30c9\u306e\u91cd\u8981\u6027<\/h2>\n<p>Java\u306ehashCode()\u30e1\u30bd\u30c3\u30c9\u3068equals()\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30c7\u30fc\u30bf\u306e\u683c\u7d0d\u3068\u53d6\u5f97\u306b\u304a\u3044\u3066\u3001Java\u306e\u30cf\u30c3\u30b7\u30e5\u30c6\u30fc\u30d6\u30eb\u30d9\u30fc\u30b9\u306e\u5b9f\u88c5\u3067\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u8a73\u7d30\u306f\u3001Java\u306b\u304a\u3051\u308bHashMap\u306e\u52d5\u4f5c\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u3044\u307e\u3059\u3002equals()\u3068hashCode()\u306e\u5b9f\u88c5\u306f\u3001\u4ee5\u4e0b\u306e\u30eb\u30fc\u30eb\u306b\u5f93\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul class=\"post-ul\">\n<li>If o1.equals(o2), then o1.hashCode() == o2.hashCode() should always be true.<\/li>\n<li>If o1.hashCode() == o2.hashCode is true, it doesn\u2019t mean that o1.equals(o2) will be true.<\/li>\n<\/ul>\n<h2>equals()\u30e1\u30bd\u30c3\u30c9\u3068hashCode()\u30e1\u30bd\u30c3\u30c9\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3059\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u306f\u3044\u3064\u3067\u3059\u304b\uff1f<\/h2>\n<p>equals() \u30e1\u30bd\u30c3\u30c9\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3059\u308b\u5834\u5408\u3001\u5b9f\u88c5\u306b\u3088\u3063\u3066\u5951\u7d04\u304c\u7834\u3089\u308c\u306a\u3044\u3088\u3046\u306b hashCode() \u30e1\u30bd\u30c3\u30c9\u3082\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u306a\u304a\u3001equals() \u3068 hashCode() \u306e\u5951\u7d04\u304c\u7834\u3089\u308c\u305f\u5834\u5408\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u4f8b\u5916\u3092\u30b9\u30ed\u30fc\u3057\u307e\u305b\u3093\u304c\u3001\u30af\u30e9\u30b9\u3092\u30cf\u30c3\u30b7\u30e5\u30c6\u30fc\u30d6\u30eb\u306e\u30ad\u30fc\u3068\u3057\u3066\u4f7f\u7528\u3059\u308b\u4e88\u5b9a\u304c\u306a\u3044\u5834\u5408\u306f\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u3002\u3057\u304b\u3057\u3001\u30af\u30e9\u30b9\u3092\u30cf\u30c3\u30b7\u30e5\u30c6\u30fc\u30d6\u30eb\u306e\u30ad\u30fc\u3068\u3057\u3066\u4f7f\u7528\u3059\u308b\u5834\u5408\u306f\u3001equals() \u3068 hashCode() \u306e\u4e21\u65b9\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306e equals() \u3068 hashCode() \u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u88c5\u306b\u983c\u3063\u3066\u3001\u30ab\u30b9\u30bf\u30e0\u30af\u30e9\u30b9\u3092 HashMap \u306e\u30ad\u30fc\u3068\u3057\u3066\u4f7f\u7528\u3057\u305f\u5834\u5408\u306b\u4f55\u304c\u8d77\u3053\u308b\u304b\u3001\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.java;\r\n\r\npublic class DataKey {\r\n\r\n\tprivate String name;\r\n\tprivate int id;\r\n\r\n        \/\/ getter and setter methods\r\n\r\n\t@Override\r\n\tpublic String toString() {\r\n\t\treturn \"DataKey [name=\" + name + \", id=\" + id + \"]\";\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>package com.scdev.java;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\n\r\npublic class HashingTest {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tMap&lt;DataKey, Integer&gt; hm = getAllData();\r\n\r\n\t\tDataKey dk = new DataKey();\r\n\t\tdk.setId(1);\r\n\t\tdk.setName(\"Pankaj\");\r\n\t\tSystem.out.println(dk.hashCode());\r\n\r\n\t\tInteger value = hm.get(dk);\r\n\r\n\t\tSystem.out.println(value);\r\n\r\n\t}\r\n\r\n\tprivate static Map&lt;DataKey, Integer&gt; getAllData() {\r\n\t\tMap&lt;DataKey, Integer&gt; hm = new HashMap&lt;&gt;();\r\n\r\n\t\tDataKey dk = new DataKey();\r\n\t\tdk.setId(1);\r\n\t\tdk.setName(\"Pankaj\");\r\n\t\tSystem.out.println(dk.hashCode());\r\n\r\n\t\thm.put(dk, 10);\r\n\r\n\t\treturn hm;\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001null\u3068\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u3053\u308c\u306f\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306ehashCode()\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u30d0\u30b1\u30c4\u3092\u898b\u3064\u3051\u308b\u305f\u3081\u3067\u3059\u3002HashMap\u306e\u30ad\u30fc\u306b\u306f\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u3044\u305f\u3081\u3001\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\u30ad\u30fc\u3092\u518d\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30cf\u30c3\u30b7\u30e5\u30b3\u30fc\u30c9\u306e\u5024\u304c\u7570\u306a\u308b\u305f\u3081\u3001\u5024\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002<\/p>\n<h2>equals\uff08\uff09\u30e1\u30bd\u30c3\u30c9\u3068hashCode\uff08\uff09\u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u88c5<\/h2>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564a47edaa94e2bdf7c39fb\/18-0.png\" alt=\"eclipse generate hashCode and equals method\" \/><\/div>\n<pre class=\"post-pre\"><code>@Override\r\npublic int hashCode() {\r\n\tfinal int prime = 31;\r\n\tint result = 1;\r\n\tresult = prime * result + id;\r\n\tresult = prime * result + ((name == null) ? 0 : name.hashCode());\r\n\treturn result;\r\n}\r\n\r\n@Override\r\npublic boolean equals(Object obj) {\r\n\tif (this == obj)\r\n\t\treturn true;\r\n\tif (obj == null)\r\n\t\treturn false;\r\n\tif (getClass() != obj.getClass())\r\n\t\treturn false;\r\n\tDataKey other = (DataKey) obj;\r\n\tif (id != other.id)\r\n\t\treturn false;\r\n\tif (name == null) {\r\n\t\tif (other.name != null)\r\n\t\t\treturn false;\r\n\t} else if (!name.equals(other.name))\r\n\t\treturn false;\r\n\treturn true;\r\n}\r\n<\/code><\/pre>\n<p>equals()\u30e1\u30bd\u30c3\u30c9\u3068hashCode()\u30e1\u30bd\u30c3\u30c9\u306e\u4e21\u65b9\u304c\u540c\u3058\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u4f7f\u7528\u3057\u3066\u8a08\u7b97\u3092\u884c\u3063\u3066\u3044\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u305d\u308c\u3089\u306e\u5951\u7d04\u304c\u6709\u52b9\u306a\u307e\u307e\u3067\u3042\u308b\u3053\u3068\u304c\u4fdd\u8a3c\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3082\u3057\u3082\u30c6\u30b9\u30c8\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u518d\u5b9f\u884c\u3059\u308b\u3068\u3001\u30de\u30c3\u30d7\u304b\u3089\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\u3057\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306f10\u3092\u51fa\u529b\u3057\u307e\u3059\u3002\u307e\u305f\u3001Project Lombok\u3092\u4f7f\u7528\u3057\u3066\u3001equals\u30e1\u30bd\u30c3\u30c9\u3068hashCode\u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u88c5\u3092\u81ea\u52d5\u751f\u6210\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30cf\u30c3\u30b7\u30e5\u885d\u7a81\u3068\u306f\u4f55\u3067\u3059\u304b\uff1f (What is a hash collision?)<\/h2>\n<p>\u975e\u5e38\u306b\u5358\u7d14\u306b\u8a00\u3048\u3070\u3001Java\u306e\u30cf\u30c3\u30b7\u30e5\u30c6\u30fc\u30d6\u30eb\u306e\u5b9f\u88c5\u3067\u306f\u3001get\u64cd\u4f5c\u3068put\u64cd\u4f5c\u306b\u6b21\u306e\u30ed\u30b8\u30c3\u30af\u304c\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u6700\u521d\u306b\u3001\u300ckey\uff08\u30cf\u30c3\u30b7\u30e5\u30b3\u30fc\u30c9\uff09\u300d\u3092\u4f7f\u3063\u3066\u4f7f\u7528\u3059\u308b\u300c\u30d0\u30b1\u30c3\u30c8\u300d\u3092\u7279\u5b9a\u3057\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u540c\u3058\u30cf\u30c3\u30b7\u30e5\u30b3\u30fc\u30c9\u3092\u6301\u3064\u30d0\u30b1\u30c3\u30c8\u306b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u3001put\u64cd\u4f5c\u306e\u305f\u3081\u306b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u8ffd\u52a0\u3057\u3001get\u64cd\u4f5c\u306e\u305f\u3081\u306b\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>\u540c\u3058\u30cf\u30c3\u30b7\u30e5\u30b3\u30fc\u30c9\u3092\u6301\u3064\u4ed6\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u30d0\u30b1\u30c3\u30c8\u306b\u5b58\u5728\u3059\u308b\u5834\u5408\u3001\u300ckey\u300d\u306eequals()\u30e1\u30bd\u30c3\u30c9\u304c\u4f7f\u308f\u308c\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>equals()\u304ctrue\u3092\u8fd4\u3057\u3001put\u64cd\u4f5c\u3067\u3042\u308b\u5834\u5408\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5024\u304c\u4e0a\u66f8\u304d\u3055\u308c\u307e\u3059\u3002<br \/>\nequals()\u304cfalse\u3092\u8fd4\u3057\u3001put\u64cd\u4f5c\u3067\u3042\u308b\u5834\u5408\u3001\u65b0\u3057\u3044\u30a8\u30f3\u30c8\u30ea\u304c\u30d0\u30b1\u30c3\u30c8\u306b\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002<br \/>\nequals()\u304ctrue\u3092\u8fd4\u3057\u3001get\u64cd\u4f5c\u3067\u3042\u308b\u5834\u5408\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5024\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<br \/>\nequals()\u304cfalse\u3092\u8fd4\u3057\u3001get\u64cd\u4f5c\u3067\u3042\u308b\u5834\u5408\u3001null\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564a47edaa94e2bdf7c39fb\/24-0.png\" alt=\"java hashmap, how hashmap works in java\" \/><\/div>\n<h2>\u3082\u3057hashCode()\u3068equals()\u306e\u4e21\u65b9\u3092\u5b9f\u88c5\u3057\u306a\u304b\u3063\u305f\u3089\u3001\u3069\u3046\u306a\u308b\u3067\u3057\u3087\u3046\u304b\uff1f<\/h2>\n<p>\u4e0a\u8a18\u3067\u65e2\u306b\u8ff0\u3079\u305f\u3088\u3046\u306b\u3001hashCode()\u304c\u5b9f\u88c5\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u3001HashMap\u306f\u30cf\u30c3\u30b7\u30e5\u30b3\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u3066\u30a8\u30f3\u30c8\u30ea\u3092\u63a2\u3059\u30d0\u30b1\u30c3\u30c8\u3092\u898b\u3064\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u305f\u3081\u3001\u5024\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002hashCode()\u306e\u307f\u3092\u4f7f\u7528\u3057\u3066equals()\u3092\u5b9f\u88c5\u3057\u306a\u3044\u5834\u5408\u3067\u3082\u3001value\u306f\u53d6\u5f97\u3067\u304d\u307e\u305b\u3093\u3002\u306a\u305c\u306a\u3089\u3001equals()\u30e1\u30bd\u30c3\u30c9\u306ffalse\u3092\u8fd4\u3059\u304b\u3089\u3067\u3059\u3002<\/p>\n<h2>equals()\u30e1\u30bd\u30c3\u30c9\u3068hashCode()\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u88c5\u3059\u308b\u305f\u3081\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h2>\n<ul class=\"post-ul\">\n<li>Use same properties in both equals() and hashCode() method implementations, so that their contract doesn\u2019t violate when any properties is updated.<\/li>\n<li>It\u2019s better to use immutable objects as Hash table key so that we can cache the hash code rather than calculating it on every call. That\u2019s why String is a good candidate for Hash table key because it\u2019s immutable and cache the hash code value.<\/li>\n<li>Implement hashCode() method so that least number of hash collision occurs and entries are evenly distributed across all the buckets.<\/li>\n<\/ul>\n<p>\u5f53\u793e\u306eGitHub\u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089\u5b8c\u5168\u306a\u30b3\u30fc\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java\u306eequals()\u30e1\u30bd\u30c3\u30c9\u3068hashCode()\u30e1\u30bd\u30c3\u30c9\u306f\u3001Object\u30af\u30e9\u30b9\u306b\u5b58\u5728\u3057\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u3059\u3079\u3066\u306eJava\u30af\u30e9\u30b9\u306f\u3001equals()\u304a\u3088\u3073hashCode()\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u5b9f\u88c5\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u3053\u306e\u6295\u7a3f\u3067 [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[26,61],"class_list":["post-819","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\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\u3002 - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"Java\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\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\u306eequals\u3068hashcode\u306f\u540c\u3058\u3067\u3059\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\u3002\" \/>\n<meta property=\"og:description\" content=\"Java\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\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\u306eequals\u3068hashcode\u306f\u540c\u3058\u3067\u3059\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-06T00:45:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-31T17:44:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564a47edaa94e2bdf7c39fb\/18-0.png\" \/>\n<meta name=\"author\" content=\"\u685c, \u6625\u6a39\" \/>\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=\"\u685c, \u6625\u6a39\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"13\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%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82\/\",\"name\":\"Java\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\u3002 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\"},\"datePublished\":\"2023-01-06T00:45:29+00:00\",\"dateModified\":\"2025-07-31T17:44:44+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/ff22288af1a5455571aff7586b0fb341\"},\"description\":\"Java\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\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%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/ja\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\u3002\"}]},{\"@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\/ff22288af1a5455571aff7586b0fb341\",\"name\":\"\u685c, \u6625\u6a39\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cee48863f3d4fd7fef222498f3e71b82312aee42b7257a2dbde56394ca4e19de?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cee48863f3d4fd7fef222498f3e71b82312aee42b7257a2dbde56394ca4e19de?s=96&d=mm&r=g\",\"caption\":\"\u685c, \u6625\u6a39\"},\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/author\/sakuraharuki\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Java\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\u3002 - Blog - Silicon Cloud","description":"Java\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\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\u306eequals\u3068hashcode\u306f\u540c\u3058\u3067\u3059\u3002\/","og_locale":"ja_JP","og_type":"article","og_title":"Java\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\u3002","og_description":"Java\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\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\u306eequals\u3068hashcode\u306f\u540c\u3058\u3067\u3059\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-01-06T00:45:29+00:00","article_modified_time":"2025-07-31T17:44:44+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564a47edaa94e2bdf7c39fb\/18-0.png"}],"author":"\u685c, \u6625\u6a39","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u685c, \u6625\u6a39","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"13\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82\/","url":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82\/","name":"Java\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\u3002 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website"},"datePublished":"2023-01-06T00:45:29+00:00","dateModified":"2025-07-31T17:44:44+00:00","author":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/ff22288af1a5455571aff7586b0fb341"},"description":"Java\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\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%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/ja\/blog\/"},{"@type":"ListItem","position":2,"name":"Java\u306eequals()\u3068hashCode()\u306f\u540c\u3058\u3067\u3059\u3002"}]},{"@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\/ff22288af1a5455571aff7586b0fb341","name":"\u685c, \u6625\u6a39","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cee48863f3d4fd7fef222498f3e71b82312aee42b7257a2dbde56394ca4e19de?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cee48863f3d4fd7fef222498f3e71b82312aee42b7257a2dbde56394ca4e19de?s=96&d=mm&r=g","caption":"\u685c, \u6625\u6a39"},"url":"https:\/\/www.silicloud.com\/ja\/blog\/author\/sakuraharuki\/"},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeequals%e3%81%a8hashcode%e3%81%af%e5%90%8c%e3%81%98%e3%81%a7%e3%81%99%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/819","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\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/comments?post=819"}],"version-history":[{"count":1,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/819\/revisions"}],"predecessor-version":[{"id":45411,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/819\/revisions\/45411"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/media?parent=819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/categories?post=819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/tags?post=819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}