{"id":194583,"date":"2020-10-31T05:10:32","date_gmt":"2020-10-30T21:10:32","guid":{"rendered":"http:\/\/4563.org\/?p=194583"},"modified":"2020-10-31T05:10:32","modified_gmt":"2020-10-30T21:10:32","slug":"%e6%89%93%e6%89%b0%e4%b8%80%e4%b8%8b%ef%bc%8c%e8%bf%99%e4%b8%aa-java-%e4%bb%a3%e7%a0%81%e4%b8%ba%e4%bb%80%e4%b9%88%e6%8a%a5%e7%a9%ba%e6%8c%87%e9%92%88%e9%94%99%e8%af%af%e5%95%8a%ef%bc%8c%e5%ae%9e","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=194583","title":{"rendered":"\u6253\u6270\u4e00\u4e0b\uff0c\u8fd9\u4e2a Java \u4ee3\u7801\u4e3a\u4ec0\u4e48\u62a5\u7a7a\u6307\u9488\u9519\u8bef\u554a\uff0c\u5b9e\u73b0\u6df1 clone"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6253\u6270\u4e00\u4e0b\uff0c\u8fd9\u4e2a Java \u4ee3\u7801\u4e3a\u4ec0\u4e48\u62a5\u7a7a\u6307\u9488\u9519\u8bef\u554a\uff0c\u5b9e\u73b0\u6df1 clone               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : proxytoworld <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4ee3\u7801\uff1a<\/p>\n<pre><code>package deepcopy;  public class DeepCopy {     static class Body implements Cloneable {         public Head head;          public Body() {         }          public Body(Head head) {             this.head = head;         }         \/\/\u91cd\u5199 clone \u65b9\u6cd5         @Override         protected Object clone() throws CloneNotSupportedException {             Body newBody = (Body) super.clone();             newBody.head = (Head) head.clone();             return newBody;         }     }      static class Head implements Cloneable {         public Face faces;          public Head() {         }          public Head(Face face) {             this.faces = face;         }         \/\/\u91cd\u5199 clone \u65b9\u6cd5         @Override         protected Object clone() throws CloneNotSupportedException {             Head head = (Head) super.clone();             head.faces = (Face)this.faces.clone();             return head;         }     }      static class Face implements Cloneable{         \/\/\u91cd\u5199 clone \u65b9\u6cd5         @Override         protected Object clone() throws CloneNotSupportedException{             return super.clone();         }     }      public static void main(String[] args) throws CloneNotSupportedException {         Body body = new Body(new Head());         Body body1 = (Body) body.clone();         System.out.println(body == body1);         System.out.println(body.head == body1.head);         System.out.println(body.head.faces == body1.head.faces);         System.out.println(body.head);         System.out.println(body1.head);     } } <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>1<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4216101\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lwlizhe <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u989d\uff0c\u4e0d\u77e5\u9053\u662f\u4e0d\u662f\u5168\u90e8\u4ee3\u7801\u2026\u2026<\/p>\n<p>\u4e0d\u8fc7\u6211\u611f\u89c9\u8fd9\u79cd\u7a7a\u6307\u9488\u5e94\u8be5\u662f\u6700\u7b80\u5355\u7684\u9519\u8bef\u4e86\u54c8\u2026\u2026\u8fd9\u79cd\u95ee\u9898\u81ea\u5df1\u770b\u4e0b\u62a5\u9519\u4fe1\u606f\u2026\u2026\u6211\u611f\u89c9\u8fd9\u79cd\u95ee\u9898\u6ca1\u591a\u5927\u610f\u4e49\u2026\u2026<\/p>\n<p>\u56de\u6b63\u9898<\/p>\n<p>\u4e4d\u770b\u5e94\u8be5\u662f head \u4e2d face \u4e3a\u7a7a\u5bfc\u81f4\u7684\uff0c\u8ddf\u62f7\u4e0d\u62f7\u8d1d\u597d\u50cf\u6ca1\u4ec0\u4e48\u5173\u7cfb\uff0cbody.clone \u8c03\u7528\u4e86 head.clone\uff0chead.clone \u8c03\u7528\u4e86 face.clone\uff0c\u7136\u800c face \u662f\u7a7a\u7684                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6253\u6270\u4e00\u4e0b\uff0c\u8fd9\u4e2a Java \u4ee3\u7801\u4e3a\u4ec0&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/194583"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=194583"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/194583\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=194583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=194583"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=194583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}