{"id":592,"date":"2023-08-27T22:06:27","date_gmt":"2023-05-27T19:13:10","guid":{"rendered":"https:\/\/www.silicloud.com\/ja\/blog\/index.php\/2023\/11\/30\/java%e3%81%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0\/"},"modified":"2025-08-01T00:53:24","modified_gmt":"2025-07-31T15:53:24","slug":"java%e3%81%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0\/","title":{"rendered":"Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 &#8211; Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0"},"content":{"rendered":"<p>\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u3068\u306f\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30b3\u30d4\u30fc\u3092\u4f5c\u308b\u30d7\u30ed\u30bb\u30b9\u3067\u3059\u3002Java\u306eObject\u30af\u30e9\u30b9\u306b\u306f\u3001\u65e2\u5b58\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30b3\u30d4\u30fc\u3092\u8fd4\u3059\u30cd\u30a4\u30c6\u30a3\u30d6\u306aclone()\u30e1\u30bd\u30c3\u30c9\u304c\u4ed8\u5c5e\u3057\u3066\u3044\u307e\u3059\u3002Java\u3067\u306fObject\u304c\u30d9\u30fc\u30b9\u30af\u30e9\u30b9\u3067\u3042\u308b\u305f\u3081\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u5168\u3066\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>Java\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u8907\u88fd<\/h2>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564965fdaa94e2bdf7bfabd\/2-0.png\" alt=\"java clone object\" \/><\/div>\n<pre class=\"post-pre\"><code>package com.scdev.cloning;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Iterator;\r\nimport java.util.Map;\r\n\r\npublic class Employee implements Cloneable {\r\n\r\n\tprivate int id;\r\n\r\n\tprivate String name;\r\n\r\n\tprivate Map&lt;String, String&gt; props;\r\n\r\n\tpublic int getId() {\r\n\t\treturn id;\r\n\t}\r\n\r\n\tpublic void setId(int id) {\r\n\t\tthis.id = id;\r\n\t}\r\n\r\n\tpublic String getName() {\r\n\t\treturn name;\r\n\t}\r\n\r\n\tpublic void setName(String name) {\r\n\t\tthis.name = name;\r\n\t}\r\n\r\n\tpublic Map&lt;String, String&gt; getProps() {\r\n\t\treturn props;\r\n\t}\r\n\r\n\tpublic void setProps(Map&lt;String, String&gt; p) {\r\n\t\tthis.props = p;\r\n\t}\r\n\r\n\t @Override\r\n\t public Object clone() throws CloneNotSupportedException {\r\n\t return super.clone();\r\n\t }\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u79c1\u305f\u3061\u306fObject clone()\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u304a\u308a\u3001\u305d\u306e\u305f\u3081\u306bCloneable\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u5b9f\u88c5\u3057\u3066\u3044\u307e\u3059\u3002\u79c1\u305f\u3061\u306f\u30b9\u30fc\u30d1\u30fc\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9\u3001\u3064\u307e\u308aObject clone()\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e clone() \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b<\/h2>\n<p>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30b3\u30d4\u30fc\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306eclone()\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u30c6\u30b9\u30c8\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.cloning;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\n\r\npublic class CloningTest {\r\n\r\n\tpublic static void main(String[] args) throws CloneNotSupportedException {\r\n\r\n\t\tEmployee emp = new Employee();\r\n\r\n\t\temp.setId(1);\r\n\t\temp.setName(\"Pankaj\");\r\n\t\tMap&lt;String, String&gt; props = new HashMap&lt;&gt;();\r\n\t\tprops.put(\"salary\", \"10000\");\r\n\t\tprops.put(\"city\", \"Bangalore\");\r\n\t\temp.setProps(props);\r\n\r\n\t\tEmployee clonedEmp = (Employee) emp.clone();\r\n\r\n\t\t\/\/ Check whether the emp and clonedEmp attributes are same or different\r\n\t\tSystem.out.println(\"emp and clonedEmp == test: \" + (emp == clonedEmp));\r\n\t\t\r\n\t\tSystem.out.println(\"emp and clonedEmp HashMap == test: \" + (emp.getProps() == clonedEmp.getProps()));\r\n\t\t\r\n\t\t\/\/ Let's see the effect of using default cloning\r\n\t\t\r\n\t\t\/\/ change emp props\r\n\t\temp.getProps().put(\"title\", \"CEO\");\r\n\t\temp.getProps().put(\"city\", \"New York\");\r\n\t\tSystem.out.println(\"clonedEmp props:\" + clonedEmp.getProps());\r\n\r\n\t\t\/\/ change emp name\r\n\t\temp.setName(\"new\");\r\n\t\tSystem.out.println(\"clonedEmp name:\" + clonedEmp.getName());\r\n\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u51fa\u529b:<\/p>\n<pre class=\"post-pre\"><code>emp and clonedEmp == test: false\r\nemp and clonedEmp HashMap == test: true\r\nclonedEmp props:{city=New York, salary=10000, title=CEO}\r\nclonedEmp name:Pankaj\r\n<\/code><\/pre>\n<h2>\u30e9\u30f3\u30bf\u30a4\u30e0\u3067\u306eCloneNotSupportedException<\/h2>\n<p>\u3082\u3057\u79c1\u305f\u3061\u306eEmployee\u30af\u30e9\u30b9\u304cCloneable\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u5b9f\u88c5\u3057\u306a\u3044\u5834\u5408\u3001\u4e0a\u8a18\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306fCloneNotSupportedException\u306e\u5b9f\u884c\u6642\u4f8b\u5916\u3092\u30b9\u30ed\u30fc\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>Exception in thread \"main\" java.lang.CloneNotSupportedException: com.scdev.cloning.Employee\r\n\tat java.lang.Object.clone(Native Method)\r\n\tat com.scdev.cloning.Employee.clone(Employee.java:41)\r\n\tat com.scdev.cloning.CloningTest.main(CloningTest.java:19)\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564965fdaa94e2bdf7bfabd\/13-0.png\" alt=\"Java CloneNotSupportedException\" \/><\/div>\n<h2>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u3092\u7406\u89e3\u3059\u308b<\/h2>\n<p>\u4e0a\u8a18\u306e\u51fa\u529b\u3092\u8abf\u3079\u3066\u3001Object\u306eclone()\u30e1\u30bd\u30c3\u30c9\u306e\u52d5\u4f5c\u3092\u7406\u89e3\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>emp\u3068clonedEmp == test: false: \u3053\u308c\u306f\u3001emp\u3068clonedEmp\u304c\u540c\u3058\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53c2\u7167\u3057\u3066\u3044\u306a\u3044\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002\u3053\u308c\u306f\u3001Java\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u306e\u8981\u4ef6\u3068\u4e00\u81f4\u3057\u3066\u3044\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>emp\u3068clonedEmp\u306eHashMap == test: true: \u3057\u305f\u304c\u3063\u3066\u3001emp\u3068clonedEmp\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5909\u6570\u306f\u540c\u3058\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53c2\u7167\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306f\u3001\u57fa\u306b\u306a\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5024\u3092\u5909\u66f4\u3059\u308b\u3068\u3001\u6df1\u523b\u306a\u30c7\u30fc\u30bf\u6574\u5408\u6027\u306e\u554f\u984c\u306b\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u5024\u306e\u5909\u66f4\u306f\u30af\u30ed\u30fc\u30f3\u3055\u308c\u305f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u3082\u53cd\u6620\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>clonedEmp\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\uff1a{city=New York, salary=10000, title=CEO}\uff1aclonedEmp\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u5909\u66f4\u306f\u52a0\u3048\u3066\u3044\u307e\u305b\u3093\u304c\u3001emp\u3068clonedEmp\u306e\u5909\u6570\u306f\u540c\u3058\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53c2\u7167\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u5909\u66f4\u304c\u52a0\u3048\u3089\u308c\u307e\u3057\u305f\u3002\u3053\u308c\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9\u304c\u30b7\u30e3\u30ed\u30fc\u30b3\u30d4\u30fc\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u3067\u3059\u3002\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u30d7\u30ed\u30bb\u30b9\u3067\u5b8c\u5168\u306b\u5207\u308a\u96e2\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u305f\u3044\u5834\u5408\u306b\u306f\u554f\u984c\u306b\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001Object\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9\u3092\u9069\u5207\u306b\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>clonedEmp\u306e\u540d\u524d\uff1aPankaj\uff1a\u4f55\u304c\u8d77\u3053\u3063\u305f\u306e\u3067\u3057\u3087\u3046\u304b\uff1femp\u306e\u540d\u524d\u3092\u5909\u66f4\u3057\u307e\u3057\u305f\u304c\u3001clonedEmp\u306e\u540d\u524d\u306f\u5909\u308f\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u3053\u308c\u306f\u3001String\u304c\u4e0d\u5909\u3067\u3042\u308b\u305f\u3081\u3067\u3059\u3002\u3057\u305f\u304c\u3063\u3066\u3001emp\u306e\u540d\u524d\u3092\u8a2d\u5b9a\u3059\u308b\u3068\u3001\u65b0\u3057\u3044\u6587\u5b57\u5217\u304c\u4f5c\u6210\u3055\u308c\u3001emp\u306e\u540d\u524d\u306e\u53c2\u7167\u304c\u3053\u308c.name = name;\u3067\u5909\u66f4\u3055\u308c\u307e\u3059\u3002\u3057\u305f\u304c\u3063\u3066\u3001clonedEmp\u306e\u540d\u524d\u306f\u5909\u308f\u308a\u307e\u305b\u3093\u3002\u540c\u69d8\u306e\u52d5\u4f5c\u306f\u3001\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u306e\u5909\u6570\u306b\u5bfe\u3057\u3066\u3082\u898b\u3089\u308c\u307e\u3059\u3002\u3057\u305f\u304c\u3063\u3066\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5185\u306b\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u3068\u4e0d\u5909\u5909\u6570\u3057\u304b\u306a\u3044\u5834\u5408\u3001Java\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u306f\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u3002<\/ol>\n<h2>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u8907\u88fd\u306e\u7a2e\u985e (Obujekuto no fukusei no shurui)<\/h2>\n<p>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u306b\u306f\u3001\u30b7\u30e3\u30ed\u30fc\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u3068\u30c7\u30a3\u30fc\u30d7\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u306e2\u3064\u306e\u30bf\u30a4\u30d7\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u308c\u305e\u308c\u3092\u7406\u89e3\u3057\u3001Java\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u3092\u5b9f\u88c5\u3059\u308b\u6700\u826f\u306e\u65b9\u6cd5\u3092\u898b\u3064\u3051\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>1. \u6d45\u3044\u30af\u30ed\u30fc\u30cb\u30f3\u30b0<\/h3>\n<p>Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5b9f\u88c5\u306f\u3001\u6d45\u3044\u30b3\u30d4\u30fc\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30b3\u30d4\u30fc\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u53cd\u5c04API\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u30b9\u30cb\u30da\u30c3\u30c8\u306f\u3001\u6d45\u3044\u30b3\u30d4\u30fc\u306e\u5b9f\u88c5\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>@Override\r\n public Object clone() throws CloneNotSupportedException {\r\n \r\n\t Employee e = new Employee();\r\n\t e.setId(this.id);\r\n\t e.setName(this.name);\r\n\t e.setProps(this.props);\r\n\t return e;\r\n}\r\n<\/code><\/pre>\n<h3>\uff12. \u30c7\u30a3\u30fc\u30d7\u30af\u30ed\u30fc\u30cb\u30f3\u30b0<\/h3>\n<p>\u6df1\u3044\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u3067\u306f\u3001\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\uff11\u3064\u305a\u3064\u30b3\u30d4\u30fc\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3082\u3057\u30ea\u30b9\u30c8\u3084\u30de\u30c3\u30d7\u306a\u3069\u306e\u30cd\u30b9\u30c8\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6301\u3064\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u305d\u308c\u3089\u3092\uff11\u3064\u305a\u3064\u30b3\u30d4\u30fc\u3059\u308b\u30b3\u30fc\u30c9\u3092\u66f8\u304b\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002\u3060\u304b\u3089\u3053\u305d\u3001\u3053\u308c\u306f\u6df1\u3044\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u3084\u6df1\u3044\u30b3\u30d4\u30fc\u3068\u547c\u3070\u308c\u3066\u3044\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306e\u3088\u3046\u306b\u3001Employee\u306eclone\u30e1\u30bd\u30c3\u30c9\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3059\u308b\u3053\u3068\u3067\u6df1\u3044\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>public Object clone() throws CloneNotSupportedException {\r\n\r\n\tObject obj = super.clone(); \/\/utilize clone Object method\r\n\r\n\tEmployee emp = (Employee) obj;\r\n\r\n\t\/\/ deep cloning for immutable fields\r\n\temp.setProps(null);\r\n\tMap&lt;String, String&gt; hm = new HashMap&lt;&gt;();\r\n\tString key;\r\n\tIterator&lt;String&gt; it = this.props.keySet().iterator();\r\n\t\/\/ Deep Copy of field by field\r\n\twhile (it.hasNext()) {\r\n\t\tkey = it.next();\r\n\t\thm.put(key, this.props.get(key));\r\n\t}\r\n\temp.setProps(hm);\r\n\t\r\n\treturn emp;\r\n}\r\n<\/code><\/pre>\n<p>\u3053\u306eclone()\u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u88c5\u306b\u3088\u308a\u3001\u79c1\u305f\u3061\u306e\u30c6\u30b9\u30c8\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u4ee5\u4e0b\u306e\u51fa\u529b\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>emp and clonedEmp == test: false\r\nemp and clonedEmp HashMap == test: false\r\nclonedEmp props:{city=Bangalore, salary=10000}\r\nclonedEmp name:Pankaj\r\n<\/code><\/pre>\n<p>\u307b\u3068\u3093\u3069\u306e\u5834\u5408\u3001\u3053\u308c\u304c\u79c1\u305f\u3061\u306e\u671b\u3080\u3053\u3068\u3067\u3059\u3002clone()\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u5143\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3068\u5b8c\u5168\u306b\u5207\u308a\u96e2\u3055\u308c\u305f\u65b0\u3057\u3044\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u8fd4\u3059\u3079\u304d\u3067\u3059\u3002\u3057\u305f\u304c\u3063\u3066\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u3067Object clone\u3068\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u3092\u4f7f\u7528\u3057\u3088\u3046\u3068\u601d\u3063\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u6ce8\u610f\u6df1\u304f\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3057\u3001\u53ef\u5909\u30d5\u30a3\u30fc\u30eb\u30c9\u306b\u6c17\u3092\u4ed8\u3051\u3066\u9069\u5207\u306b\u884c\u3063\u3066\u304f\u3060\u3055\u3044\u3002\u30af\u30e9\u30b9\u304c\u4ed6\u306e\u30af\u30e9\u30b9\u3092\u62e1\u5f35\u3057\u3001\u3055\u3089\u306b\u4ed6\u306e\u30af\u30e9\u30b9\u3092\u62e1\u5f35\u3057\u3066\u3044\u308b\u5834\u5408\u3001\u3053\u308c\u306f\u56f0\u96e3\u306a\u4f5c\u696d\u306b\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u3059\u3079\u3066\u306e\u53ef\u5909\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u30c7\u30a3\u30fc\u30d7\u30b3\u30d4\u30fc\u3092\u884c\u3046\u305f\u3081\u306b\u3001Object\u306e\u7d99\u627f\u968e\u5c64\u5168\u4f53\u3092\u8fbf\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>\u30b7\u30ea\u30a2\u30e9\u30a4\u30ba\u3092\u4f7f\u7528\u3057\u305f\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\uff1f (Shiriarai o shiy\u014d shita kur\u014dningu?)<\/h2>\n<p>\u624b\u8efd\u306b\u6df1\u3044\u30af\u30ed\u30fc\u30f3\u3092\u4f5c\u6210\u3059\u308b\u65b9\u6cd5\u306e\u4e00\u3064\u306f\u3001\u30b7\u30ea\u30a2\u30e9\u30a4\u30ba\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3059\u3002\u3057\u304b\u3057\u3001\u30b7\u30ea\u30a2\u30e9\u30a4\u30ba\u306f\u8ca0\u8377\u304c\u9ad8\u3044\u624b\u7d9a\u304d\u3067\u3042\u308a\u3001\u30af\u30e9\u30b9\u306fSerializable\u30a4\u30f3\u30bf\u30d5\u30a7\u30fc\u30b9\u3092\u5b9f\u88c5\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u307e\u305f\u3001\u5168\u3066\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3068\u30b9\u30fc\u30d1\u30fc\u30af\u30e9\u30b9\u3082Serializable\u3092\u5b9f\u88c5\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<h2>Apache Commons Util \u3092\u4f7f\u7528\u3059\u308b<\/h2>\n<p>\u3082\u3057\u3059\u3067\u306b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067Apache Commons Util\u306e\u30af\u30e9\u30b9\u3092\u4f7f\u7528\u3057\u3066\u304a\u308a\u3001\u3055\u3089\u306b\u305d\u306e\u30af\u30e9\u30b9\u304c\u30b7\u30ea\u30a2\u30e9\u30a4\u30ba\u53ef\u80fd\u3067\u3042\u308b\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"post-pre\"><code>Employee clonedEmp = org.apache.commons.lang3.SerializationUtils.clone(emp);\r\n<\/code><\/pre>\n<h2>\u30b3\u30d4\u30fc\u306e\u305f\u3081\u306e\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u7528\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf<\/h2>\n<p>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30b3\u30d4\u30fc\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u3001\u30b3\u30d4\u30fc\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306eclone()\u30e1\u30bd\u30c3\u30c9\u306b\u4f9d\u5b58\u3059\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u4f8b\u3048\u3070\u3001\u6b21\u306e\u30b3\u30fc\u30c9\u306e\u3088\u3046\u306b\u3001Employee\u306e\u30b3\u30d4\u30fc\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u6301\u3064\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>public Employee(Employee emp) {\r\n\t\r\n\tthis.setId(emp.getId());\r\n\tthis.setName(emp.getName());\r\n\t\r\n\tMap&lt;String, String&gt; hm = new HashMap&lt;&gt;();\r\n\tString key;\r\n\tIterator&lt;String&gt; it = emp.getProps().keySet().iterator();\r\n\t\/\/ Deep Copy of field by field\r\n\twhile (it.hasNext()) {\r\n\t\tkey = it.next();\r\n\t\thm.put(key, emp.getProps().get(key));\r\n\t}\r\n\tthis.setProps(hm);\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u5f93\u696d\u54e1\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30b3\u30d4\u30fc\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f\u3001Employee clonedEmp = new Employee(emp); \u3092\u4f7f\u7528\u3057\u3066\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u30af\u30e9\u30b9\u306b\u591a\u304f\u306e\u5909\u6570\u3001\u7279\u306b\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u3084\u4e0d\u5909\u578b\u304c\u3042\u308b\u5834\u5408\u3001\u30b3\u30d4\u30fc\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u66f8\u304f\u3053\u3068\u306f\u9762\u5012\u306a\u4f5c\u696d\u306b\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>\u4ee5\u4e0b\u306eJava\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u306b\u3064\u3044\u3066\u8ff0\u3079\u307e\u3059\u3002<\/h2>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u30c7\u30d5\u30a9\u30eb\u30c8\u306eObject\u306eclone()\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30af\u30e9\u30b9\u304c\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u3068\u4e0d\u5909\u306e\u5909\u6570\u3092\u6301\u3063\u3066\u3044\u308b\u5834\u5408\u3084\u3001\u30b7\u30e3\u30ed\u30fc\u30b3\u30d4\u30fc\u304c\u5fc5\u8981\u306a\u5834\u5408\u306b\u306e\u307f\u4f7f\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u7d99\u627f\u306e\u5834\u5408\u306f\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30ec\u30d9\u30eb\u307e\u3067\u62e1\u5f35\u3057\u3066\u3044\u308b\u3059\u3079\u3066\u306e\u30af\u30e9\u30b9\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>\u307e\u305f\u3001\u30af\u30e9\u30b9\u306e\u307b\u3068\u3093\u3069\u304c\u53ef\u5909\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u6301\u3063\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u30b3\u30d4\u30fc\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3055\u308c\u305fclone\u30e1\u30bd\u30c3\u30c9\u3067super.clone()\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u3067\u3001Object\u306eclone()\u30e1\u30bd\u30c3\u30c9\u3092\u5229\u7528\u3057\u3001\u53ef\u5909\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u30c7\u30a3\u30fc\u30d7\u30b3\u30d4\u30fc\u306e\u305f\u3081\u306e\u5fc5\u8981\u306a\u5909\u66f4\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30af\u30e9\u30b9\u304c\u30b7\u30ea\u30a2\u30e9\u30a4\u30ba\u53ef\u80fd\u3067\u3042\u308c\u3070\u3001\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u306b\u306f\u30b7\u30ea\u30a2\u30e9\u30a4\u30ba\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u5f71\u97ff\u304c\u3042\u308b\u305f\u3081\u3001\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u306b\u30b7\u30ea\u30a2\u30e9\u30a4\u30ba\u3092\u4f7f\u7528\u3059\u308b\u524d\u306b\u30d9\u30f3\u30c1\u30de\u30fc\u30ad\u30f3\u30b0\u3092\u884c\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30af\u30e9\u30b9\u3092\u62e1\u5f35\u3057\u3066\u3044\u3066\u3001\u30c7\u30a3\u30fc\u30d7\u30b3\u30d4\u30fc\u3092\u4f7f\u7528\u3057\u3066clone\u30e1\u30bd\u30c3\u30c9\u304c\u9069\u5207\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306eclone\u30e1\u30bd\u30c3\u30c9\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u305f\u3068\u3048\u3070\u3001Employee\u30af\u30e9\u30b9\u3067\u9069\u5207\u306b\u5b9a\u7fa9\u3055\u308c\u305fclone()\u30e1\u30bd\u30c3\u30c9\u304c\u6b21\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<p>@Override<br \/>\npublic Object clone() throws CloneNotSupportedException {<\/p>\n<p>Object obj = super.clone();<\/p>\n<p>Employee emp = (Employee) obj;<\/p>\n<p>\/\/ \u30a4\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u30c7\u30a3\u30fc\u30d7\u30b3\u30fc\u30d4\u30a3\u30f3\u30b0<br \/>\nemp.setProps(null);<br \/>\nMap&lt;String, String&gt; hm = new HashMap&lt;&gt;();<br \/>\nString key;<br \/>\nIterator it = this.props.keySet().iterator();<br \/>\n\/\/ \u30d5\u30a3\u30fc\u30eb\u30c9\u3054\u3068\u306e\u30c7\u30a3\u30fc\u30d7\u30b3\u30d4\u30fc<br \/>\nwhile (it.hasNext()) {<br \/>\nkey = it.next();<br \/>\nhm.put(key, this.props.get(key));<br \/>\n}<br \/>\nemp.setProps(hm);<\/p>\n<p>return emp;<br \/>\n}<\/p>\n<p>\u6b21\u306e\u3088\u3046\u306b\u3001\u5b50\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u3066\u3001\u30b9\u30fc\u30d1\u30fc\u30af\u30e9\u30b9\u306e\u30c7\u30a3\u30fc\u30d7\u30b3\u30fc\u30d4\u30a3\u30f3\u30b0\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>package com.scdev.cloning;<\/p>\n<p>public class EmployeeWrap extends Employee implements Cloneable {<\/p>\n<p>private String title;<\/p>\n<p>public String getTitle() {<br \/>\nreturn title;<br \/>\n}<\/p>\n<p>public void setTitle(String t) {<br \/>\nthis.title = t;<br \/>\n}<\/p>\n<p>@Override<br \/>\npublic Object clone() throws CloneNotSupportedException {<\/p>\n<p>return super.clone();<br \/>\n}<br \/>\n}<\/p>\n<p>EmployeeWrap\u30af\u30e9\u30b9\u306b\u306f\u53ef\u5909\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306f\u3042\u308a\u307e\u305b\u3093\u3057\u3001\u30b9\u30fc\u30d1\u30fc\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u88c5\u3092\u5229\u7528\u3057\u3066\u3044\u307e\u3059\u3002\u53ef\u5909\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u305d\u308c\u3089\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u30c7\u30a3\u30fc\u30d7\u30b3\u30fc\u30d4\u30a3\u30f3\u30b0\u306b\u6ce8\u610f\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u6b21\u306b\u3001\u3053\u306e\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u65b9\u6cd5\u304c\u6b63\u5e38\u306b\u6a5f\u80fd\u3059\u308b\u304b\u3069\u3046\u304b\u3092\u30c6\u30b9\u30c8\u3059\u308b\u7c21\u5358\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>package com.scdev.cloning;<\/p>\n<p>import java.util.HashMap;<br \/>\nimport java.util.Map;<\/p>\n<p>public class CloningTest {<\/p>\n<p>public static void main(String[] args) throws CloneNotSupportedException {<\/p>\n<p>EmployeeWrap empWrap = new EmployeeWrap();<\/p>\n<p>empWrap.setId(1);<br \/>\nempWrap.setName(&#8220;Pankaj&#8221;);<br \/>\nempWrap.setTitle(&#8220;CEO&#8221;);<\/p>\n<p>Map&lt;String, String&gt; props = new HashMap&lt;&gt;();<br \/>\nprops.put(&#8220;salary&#8221;, &#8220;10000&#8221;);<br \/>\nprops.put(&#8220;city&#8221;, &#8220;Bangalore&#8221;);<br \/>\nempWrap.setProps(props);<\/p>\n<p>EmployeeWrap clonedEmpWrap = (EmployeeWrap) empWrap.clone();<\/p>\n<p>empWrap.getProps().put(&#8220;1&#8221;, &#8220;1&#8221;);<\/p>\n<p>System.out.println(&#8220;empWrap\u306e\u53ef\u5909\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u5024 = &#8221; + empWrap.getProps());<\/p>\n<p>System.out.println(&#8220;clonedEmpWrap\u306e\u53ef\u5909\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u5024 = &#8221; + clonedEmpWrap.getProps());<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>\u51fa\u529b\uff1a<br \/>\nempWrap\u306e\u53ef\u5909\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u5024 = {1=1, city=Bangalore, salary=10000}<br \/>\nclonedEmpWrap\u306e\u53ef\u5909\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u5024 = {city=Bangalore, salary=10000}<\/p>\n<p>\u4e88\u60f3\u3069\u304a\u308a\u306b\u52d5\u4f5c\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u304cJava\u306b\u304a\u3051\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u306b\u95a2\u3059\u308b\u3059\u3079\u3066\u3067\u3059\u3002Java\u306eObject clone()\u30e1\u30bd\u30c3\u30c9\u3068\u3001\u305d\u308c\u3092\u9069\u5207\u306b\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3057\u3066\u4f55\u3089\u304b\u306e\u4e0d\u826f\u52b9\u679c\u3092\u907f\u3051\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3001\u5c11\u3057\u3067\u3082\u7406\u89e3\u3067\u304d\u3066\u3044\u308c\u3070\u3044\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u79c1\u306eGitHub\u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u53c2\u7167\uff1aObject clone\u306eAPI\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\u3068\u306f\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30b3\u30d4\u30fc\u3092\u4f5c\u308b\u30d7\u30ed\u30bb\u30b9\u3067\u3059\u3002Java\u306eObject\u30af\u30e9\u30b9\u306b\u306f\u3001\u65e2\u5b58\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30b3\u30d4\u30fc\u3092\u8fd4\u3059\u30cd\u30a4\u30c6\u30a3\u30d6\u306aclone()\u30e1\u30bd\u30c3\u30c9\u304c\u4ed8\u5c5e\u3057\u3066\u3044\u307e\u3059\u3002Java\u3067\u306fObject\u304c\u30d9\u30fc\u30b9\u30af\u30e9\u30b9\u3067\u3042\u308b [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[26,61],"class_list":["post-592","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\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 - Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0 - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 - Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\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\u306eobject\u30af\u30e9\u30b9\u306eclone\u30e1\u30bd\u30c3\u30c9-java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 - Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\" \/>\n<meta property=\"og:description\" content=\"Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 - Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\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\u306eobject\u30af\u30e9\u30b9\u306eclone\u30e1\u30bd\u30c3\u30c9-java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-27T19:13:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-31T15:53:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564965fdaa94e2bdf7bfabd\/2-0.png\" \/>\n<meta name=\"author\" content=\"\u6d77\u6597, \u8475\" \/>\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=\"\u6d77\u6597, \u8475\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"21\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%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0\/\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0\/\",\"name\":\"Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 - Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\"},\"datePublished\":\"2023-05-27T19:13:10+00:00\",\"dateModified\":\"2025-07-31T15:53:24+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/20cfc053626f4d45c0fa7a4e7964b5b6\"},\"description\":\"Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 - Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\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%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/ja\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 &#8211; Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\"}]},{\"@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\/20cfc053626f4d45c0fa7a4e7964b5b6\",\"name\":\"\u6d77\u6597, \u8475\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/25aec9a18954b6bfb7e4f7219c2923d62c6f0c9f4d5c0171228fe41751c0ab7a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/25aec9a18954b6bfb7e4f7219c2923d62c6f0c9f4d5c0171228fe41751c0ab7a?s=96&d=mm&r=g\",\"caption\":\"\u6d77\u6597, \u8475\"},\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/author\/kaitoaoi\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 - Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0 - Blog - Silicon Cloud","description":"Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 - Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\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\u306eobject\u30af\u30e9\u30b9\u306eclone\u30e1\u30bd\u30c3\u30c9-java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\/","og_locale":"ja_JP","og_type":"article","og_title":"Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 - Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0","og_description":"Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 - Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\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\u306eobject\u30af\u30e9\u30b9\u306eclone\u30e1\u30bd\u30c3\u30c9-java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-05-27T19:13:10+00:00","article_modified_time":"2025-07-31T15:53:24+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564965fdaa94e2bdf7bfabd\/2-0.png"}],"author":"\u6d77\u6597, \u8475","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u6d77\u6597, \u8475","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"21\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0\/","url":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0\/","name":"Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 - Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website"},"datePublished":"2023-05-27T19:13:10+00:00","dateModified":"2025-07-31T15:53:24+00:00","author":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/20cfc053626f4d45c0fa7a4e7964b5b6"},"description":"Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 - Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0\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%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/ja\/blog\/"},{"@type":"ListItem","position":2,"name":"Java\u306eObject\u30af\u30e9\u30b9\u306eclone()\u30e1\u30bd\u30c3\u30c9 &#8211; Java\u306b\u304a\u3051\u308b\u30af\u30ed\u30fc\u30cb\u30f3\u30b0"}]},{"@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\/20cfc053626f4d45c0fa7a4e7964b5b6","name":"\u6d77\u6597, \u8475","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/25aec9a18954b6bfb7e4f7219c2923d62c6f0c9f4d5c0171228fe41751c0ab7a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/25aec9a18954b6bfb7e4f7219c2923d62c6f0c9f4d5c0171228fe41751c0ab7a?s=96&d=mm&r=g","caption":"\u6d77\u6597, \u8475"},"url":"https:\/\/www.silicloud.com\/ja\/blog\/author\/kaitoaoi\/"},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%aeobject%e3%82%af%e3%83%a9%e3%82%b9%e3%81%aeclone%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89-java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b%e3%82%af%e3%83%ad%e3%83%bc%e3%83%8b%e3%83%b3%e3%82%b0\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/592","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\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/comments?post=592"}],"version-history":[{"count":1,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/592\/revisions"}],"predecessor-version":[{"id":42555,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/592\/revisions\/42555"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/media?parent=592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/categories?post=592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/tags?post=592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}