
{"id":2119,"date":"2020-08-18T13:12:53","date_gmt":"2020-08-18T05:12:53","guid":{"rendered":"http:\/\/127.0.0.2\/?p=2119"},"modified":"2020-08-23T11:15:58","modified_gmt":"2020-08-23T03:15:58","slug":"2020java%e6%95%99%e7%a8%8b%ef%bc%9a%e5%b1%80%e9%83%a8%e5%86%85%e9%83%a8%e7%b1%bb%e8%ae%bf%e9%97%ae%e5%a4%96%e9%83%a8%e5%86%85%e9%83%a8%e7%b1%bb%e5%b1%80%e9%83%a8%e5%8f%98%e9%87%8f%e4%b8%ba%e4%bb%80","status":"publish","type":"post","link":"https:\/\/www.9713job.com\/?p=2119","title":{"rendered":"2020java\u6559\u7a0b\uff1a\u5c40\u90e8\u5185\u90e8\u7c7b\u8bbf\u95ee\u5916\u90e8\u5185\u90e8\u7c7b\u5c40\u90e8\u53d8\u91cf\u4e3a\u4ec0\u4e48\u8981\u52a0final"},"content":{"rendered":"<h3>\u5c40\u90e8\u5185\u90e8\u7c7b\u8bbf\u95ee\u5916\u90e8\u5185\u90e8\u7c7b\u5c40\u90e8\u53d8\u91cf\u4e3a\u4ec0\u4e48\u8981\u52a0final<\/h3>\n<pre>public class demos{\r\n    public static void main(String[] args) {\r\n        Outer out=new Outer();\r\n        out.m1();\r\n    }\r\n}<!--more-->\r\n\r\n\r\nclass Outer{\r\n    int a=10;\r\n    public void m1(){\r\n        \/*final*\/ String str=\"Hello\";\/\/\u9ed8\u8ba4\u6dfb\u52a0final\r\n        class Inner{\r\n            int a=20;\r\n            public void m2(){\r\n                int a=30;\r\n                System.out.println(\"Inner m2()\"+str);\r\n                System.out.println(\"Inner m2()\"+a);\r\n                System.out.println(\"Inner m2()\"+this.a);\r\n                System.out.println(\"Inner m2()\"+Outer.this.a);\r\n            }\r\n        }\r\n        Inner in=new Inner();\r\n        in.m2();\r\n    }\r\n}<\/pre>\n<p>\u5c40\u90e8\u5185\u90e8\u7c7b\u5b83\u6574\u4e2a\u4f7f\u7528\u8303\u56f4\u5728\u65b9\u6cd5\u5185\u90e8\uff0c\u4f5c\u4e3a\u4e00\u4e2a\u7c7b\u6765\u8bb2\uff0c\u53ef\u4ee5new\u5b83\u7684\u5bf9\u8c61\uff0c\u90a3\u4e48\u5bf9\u8c61\u5728\u5806\u91cc\uff0c\u5c40\u90e8\u53d8\u91cf\u5728\u6808\u91cc\uff0c\u4ed6\u4eec\u56de\u6536\u65f6\u673a\u4e0d\u540c\uff0c\u6808\u91cc\u9762\u7684\u5185\u5bb9\u4f1a\u7acb\u523b\u56de\u6536\uff0c\u53ea\u8981\u8303\u56f4\u4e00\u8de8\u8d8a\u51fa\u4e86\u65b9\u6cd5\u5c31\u6ca1\u6709\u4e86\uff0c\u4f46\u662f\u5bf9\u8c61\u53ef\u4e0d\u4f1a\u7acb\u523b\u56de\u6536\uff0c\u6362\u53e5\u8bdd\u8bf4\uff0c\u8fd9\u7a0b\u5e8f\u65b9\u6cd5\u6267\u884c\u5b8c\u4e86\uff0cc\u662f\u5c40\u90e8\u53d8\u91cf\uff0c\u5b83\u4f1a\u88ab\u56de\u6536\uff0c&#8221;hello&#8221;\u662f\u4e2a\u5bf9\u8c61\uff0c\u5b83\u5728\u5806\u91cc\uff0c\u4e0d\u56de\u6536\uff0cInner in\u4e5f\u662f\u5c40\u90e8\u53d8\u91cf\uff0c\u5b83\u8981\u88ab\u56de\u6536\uff0c\u4f46\u662f\u8fd9\u4e2a\u5bf9\u8c61\u5728\u5806\u91cc\uff0c\u5b83\u4e5f\u4e0d\u56de\u6536\uff0c\u5bf9\u8c61\u4f1a\u4f34\u968f\u7740java\u865a\u62df\u673a\u7684\u5783\u573e\u6536\u96c6\u5668\u8fd0\u884c\u65f6\u56de\u6536\u3002<\/p>\n<p>\u8981\u533a\u5206\uff1a<\/p>\n<p>\u5c40\u90e8\u53d8\u91cf\u7acb\u5373\u56de\u6536\uff0c\u5bf9\u8c61\u662f\u8981\u4f34\u968f\u4e00\u4e2a\u5468\u671f\u7684\u65f6\u70b9\u505a\u5783\u573e\u6536\u96c6\u7684\u65f6\u5019\u624d\u56de\u6536\uff0c\u4ed6\u4eec\u56de\u6536\u65f6\u70b9\u4e0d\u4e00\u6837\u3002<\/p>\n<p>\u65e2\u7136\u5bf9\u8c61\u56de\u6536\u65f6\u70b9\u8981\u6bd4\u5c40\u90e8\u53d8\u91cf\u66f4\u6162\uff0c\u6709\u6ca1\u6709\u4e00\u79cd\u53ef\u80fd\u5c40\u90e8\u53d8\u91cf\u88ab\u56de\u6536\uff0c\u5bf9\u8c61\u8fd8\u5728\u5462\uff1f<\/p>\n<p>\u8fd9\u4e2a\u65b9\u6cd5\u4e00\u65e6\u6267\u884c\u5b8c\u6bd5\uff0c\u53ea\u8981\u7a0b\u5e8f\u6ca1\u505c\uff0c\u5c40\u90e8\u53d8\u91cf\u80af\u5b9a\u6ca1\u4e86\uff0c\u4f46\u662finner\u5bf9\u8c61\u8fd8\u5b58\u6d3b\u7740\uff0c\u4e0d\u8981\u62c5\u5fc3new\u00a0 inner \u5bf9\u8c61\u51fa\u5708\u5c31\u627e\u4e0d\u5230\u8fd9\u5bf9\u8c61\u4e86\u3002<\/p>\n<p>\u53ef\u4ee5\u7ee7\u627f\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u63a5\u53e3<\/p>\n<pre>public class demos{\r\n    public static void main(String[] args) {\r\n        Outer out=new Outer();\r\n        out.m1();\r\n        out.p.print();\r\n    }\r\n}\r\nclass Outer{\r\n    int a=10;\r\n    prints p=null;\r\n    public void m1(){\r\n        final String str=\"Hello\";\r\n        class Inner implements prints{\r\n            int a=20;\r\n            @Override\r\n            public void print(){\r\n                int a=30;\r\n                System.out.println(\"Inner m2()\"+str);\r\n                System.out.println(\"Inner m2()\"+a);\r\n                System.out.println(\"Inner m2()\"+this.a);\r\n                System.out.println(\"Inner m2()\"+Outer.this.a);\r\n            }\r\n        }\r\n        p=new Inner();\r\n    }\r\n}\r\ninterface prints{\r\n    void print();\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5c40\u90e8\u5185\u90e8\u7c7b\u8bbf\u95ee\u5916\u90e8\u5185\u90e8\u7c7b\u5c40\u90e8\u53d8\u91cf\u4e3a\u4ec0\u4e48\u8981\u52a0final public class demos{ public s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-2119","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/2119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2119"}],"version-history":[{"count":4,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/2119\/revisions"}],"predecessor-version":[{"id":2144,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/2119\/revisions\/2144"}],"wp:attachment":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}