{"id":457,"date":"2021-12-06T13:40:53","date_gmt":"2021-12-06T13:40:53","guid":{"rendered":"http:\/\/www.nokws.top\/?p=457"},"modified":"2021-12-06T13:40:55","modified_gmt":"2021-12-06T13:40:55","slug":"java-daimazhixingshunxu1","status":"publish","type":"post","link":"http:\/\/www.nokws.top\/index.php\/2021\/12\/06\/java-daimazhixingshunxu1\/","title":{"rendered":"Java \u4ee3\u7801\u6267\u884c\u987a\u5e8f\uff081\uff09"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u4e3b\u8981\u8bb0\u5f55\u4e0bjava\u5b9e\u4f8b\u5316\u5bf9\u8c61\u3001\u9759\u6001\u4ee3\u7801\u5757\u7b49\u4ee3\u7801\u6267\u884c\u7684\u987a\u5e8f<\/p><\/blockquote>\n\n\n\n<p>Java\u7a0b\u5e8f\u5728\u6267\u884c\u8fc7\u7a0b\u4e2d\uff0c\u7c7b\uff0c\u5bf9\u8c61\u4ee5\u53ca\u5b83\u4eec\u6210\u5458\u52a0\u8f7d\u3001\u521d\u59cb\u5316\u7684\u987a\u5e8f\u5982\u4e0b\uff1a<br>1\u3001\u9996\u5148\u52a0\u8f7d\u8981\u521b\u5efa\u5bf9\u8c61\u7684\u7c7b\u53ca\u5176\u76f4\u63a5\u4e0e\u95f4\u63a5\u7236\u7c7b\u3002<br>2\u3001\u5728\u7c7b\u88ab\u52a0\u8f7d\u7684\u540c\u65f6\u4f1a\u5c06\u9759\u6001\u6210\u5458\u8fdb\u884c\u52a0\u8f7d\uff0c\u4e3b\u8981\u5305\u62ec\u9759\u6001\u6210\u5458\u53d8\u91cf\u7684\u521d\u59cb\u5316\uff0c\u9759\u6001\u8bed\u53e5\u5757\u7684\u6267\u884c\uff0c\u5728\u52a0\u8f7d\u65f6\u6309\u4ee3\u7801\u7684\u5148\u540e\u987a\u5e8f\u8fdb\u884c\u3002<br>3\u3001\u9700\u8981\u7684\u7c7b\u52a0\u8f7d\u5b8c\u6210\u540e\uff0c\u5f00\u59cb\u521b\u5efa\u5bf9\u8c61\uff0c\u9996\u5148\u4f1a\u52a0\u8f7d\u975e\u9759\u6001\u7684\u6210\u5458\uff0c\u4e3b\u8981\u5305\u62ec\u975e\u9759\u6001\u6210\u5458\u53d8\u91cf\u7684\u521d\u59cb\u5316\uff0c\u975e\u9759\u6001\u8bed\u53e5\u5757\u7684\u6267\u884c\uff0c\u5728\u52a0\u8f7d\u65f6\u6309\u4ee3\u7801\u7684\u5148\u540e\u987a\u5e8f\u8fdb\u884c\u3002<br>4\u3001\u6700\u540e\u6267\u884c\u6784\u9020\u5668\uff0c\u6784\u9020\u5668\u6267\u884c\u5b8c\u6bd5\uff0c\u5bf9\u8c61\u751f\u6210\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5java\u5bf9\u8c61\u5b9e\u4f8b\u5316\u65f6\u7684\u987a\u5e8f\u4e3a\uff1a<\/p>\n\n\n\n<p>1\uff0c\u7236\u7c7b\u7684\u9759\u6001\u6210\u5458\u53d8\u91cf\u548c\u9759\u6001\u4ee3\u7801\u5757\u52a0\u8f7d<br>2\uff0c\u5b50\u7c7b\u7684\u9759\u6001\u6210\u5458\u53d8\u91cf\u548c\u9759\u6001\u4ee3\u7801\u5757\u52a0\u8f7d<br>3\uff0c\u7236\u7c7b\u6210\u5458\u53d8\u91cf\u548c\u65b9\u6cd5\u5757\u52a0\u8f7d<br>4\uff0c\u7236\u7c7b\u7684\u6784\u9020\u51fd\u6570\u52a0\u8f7d<br>5\uff0c\u5b50\u7c7b\u6210\u5458\u53d8\u91cf\u548c\u65b9\u6cd5\u5757\u52a0\u8f7d<br>6\uff0c\u5b50\u7c7b\u7684\u6784\u9020\u51fd\u6570\u52a0\u8f7d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class X {\r\n\tY b = new Y();\/\/\u5b9e\u4f8b\u5316\u5bf9\u8c61\r\n\tint number1 = num();\/\/\u7236\u7c7b\u4e2d\u7684\u6210\u5458\u53d8\u91cf\r\n    int num(){\/\/\u7236\u7c7b\u4e2d\u7684\u6210\u5458\u51fd\u6570\r\n        System.out.println(\"\u7236\u7c7b\u6210\u5458\u53d8\u91cfnum\u52a0\u8f7d\");\r\n        return 666;\r\n    }\r\n    static int number2=num2();\/\/\u7236\u7c7b\u4e2d\u7684\u9759\u6001\u6210\u5458\u53d8\u91cf\r\n    static int num2(){\/\/\u7236\u7c7b\u4e2d\u7684\u9759\u6001\u6210\u5458\u51fd\u6570\r\n        System.out.println(\"\u7236\u7c7b\u9759\u6001\u6210\u5458\u53d8\u91cfnum2\u52a0\u8f7d\");\r\n        return 666666;\r\n    }\r\n\tstatic {\/\/X\u4e2d\u9759\u6001\u4ee3\u7801\u5757\r\n\t\tSystem.out.print(\"\u7236\u7c7b\u4e2d\u7684\u9759\u6001\u4ee3\u7801\u5757\u52a0\u8f7d\"+\"\\n\");\r\n\t}\r\n\t {\r\n\t        System.out.println(\"\u7236\u7c7b\u666e\u901a\u65b9\u6cd5\u5757\u52a0\u8f7d\");\r\n\t }\r\n\t\/\/Y b = new Y();\r\n\tpublic X() {\r\n\t\tSystem.out.print(\"\u7236\u7c7b\u4e2d\u7684\u6784\u9020\u51fd\u6570\u52a0\u8f7d\"+\"\\n\");\r\n\t}\r\n\t\/\/Y c = new Y();\r\n}\r\n\r\nclass Y {\r\n\tstatic {\r\n\t\tSystem.out.print(\"\u7c7b\u4e2d\u8c03\u7528\u5176\u4ed6\u7c7b\u65f6\uff0c\u5176\u4ed6\u7c7b\u7684\u9759\u6001\u51fd\u6570\u52a0\u8f7d\"+\"\\n\");\r\n\t}\r\n\tY() {\r\n\t\tSystem.out.print(\"\u7c7b\u4e2d\u8c03\u7528\u5176\u4ed6\u7c7b\u65f6\uff0c\u5176\u4ed6\u7c7b\u7684\u6784\u9020\u51fd\u6570\u52a0\u8f7d\"+\"\\n\");\r\n\t}\r\n}\r\n\r\npublic class Z extends X {\r\n\tY y = new Y();\r\n\tint number = num();\/\/\u7236\u7c7b\u4e2d\u7684\u6210\u5458\u53d8\u91cf\r\n    int num(){\/\/\u5b50\u7c7b\u4e2d\u7684\u6210\u5458\u51fd\u6570\r\n        System.out.println(\"\u5b50\u7c7b\u6210\u5458\u53d8\u91cfnum\u52a0\u8f7d\");\r\n        return 555;\r\n    }\r\n    static int number2=num2();\/\/\u7236\u7c7b\u4e2d\u7684\u9759\u6001\u6210\u5458\u53d8\u91cf\r\n    static int num2(){\/\/\u7236\u7c7b\u4e2d\u7684\u9759\u6001\u6210\u5458\u51fd\u6570\r\n        System.out.println(\"\u5b50\u7c7b\u9759\u6001\u6210\u5458\u53d8\u91cfnum2\u52a0\u8f7d\");\r\n        return 55555;\r\n    }\r\n\tstatic {\r\n\t\tSystem.out.print(\"\u5b50\u7c7b\u4e2d\u7684\u9759\u6001\u4ee3\u7801\u5757\"+\"\\n\");\r\n\t}\r\n\t {\r\n\t        System.out.println(\"\u5b50\u7c7b\u666e\u901a\u65b9\u6cd5\u5757\u52a0\u8f7d\");\r\n\t }\r\n\tZ() {\r\n\t\t\/\/super();\/\/\u9ed8\u8ba4\uff0c\u4f9b\u7cfb\u7edf\u5e95\u5c42\u68c0\u67e5\u8c03\u7528\uff0c\u800c\u4e0d\u5177\u4f53\u6267\u884cclass Z\u7684\u6784\u9020\u65b9\u6cd5\r\n\t\tSystem.out.print(\"\u5b50\u7c7b\u4e2d\u7684\u6784\u9020\u51fd\u6570\u52a0\u8f7d\"+\"\\n\");\r\n\t}\r\n\r\n\tpublic static void main(String&#91;] args) {\r\n\t\tZ z=new Z(); \r\n\t}\r\n} <\/code><\/pre>\n\n\n\n<p>\u8fc7\u7a0b\uff1a\u5b50\u7c7bmain\u51fd\u6570\u4e2d\u5b9e\u4f8b\u5316\u5bf9\u8c61 z\uff0c\u5148\u52a0\u8f7d\u7236\u7c7b\uff1b<\/p>\n\n\n\n<p>           \u7236\u7c7b\u9759\u6001\u6210\u5458\u53d8\u91cf\/\u7236\u7c7b\u9759\u6001\u4ee3\u7801\u5757\uff08\u987a\u5e8f\u6267\u884c\uff09>\u5b50\u7c7b\u9759\u6001 \uff1b<\/p>\n\n\n\n<p>           \u82e5\u7236\u7c7b\u4e2d\u8c03\u7528\u5176\u4ed6\u7c7b\uff0c\u5728\u7236\u7c7b\u548c\u5b50\u7c7b\u7684\u9759\u6001\u5185\u5bb9\u6267\u884c\u5b8c\u6210\u540e \uff0c\u518d\u6267\u884c\uff1b<\/p>\n\n\n\n<p>           \u7236\u7c7b\u666e\u901a\u65b9\u6cd5\u5757>\u6784\u9020\u51fd\u6570>   <\/p>\n\n\n\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n\n\n\n<p>\u7236\u7c7b\u9759\u6001\u6210\u5458\u53d8\u91cfnum2\u52a0\u8f7d  \/\/\u9759\u6001\u5185\u5bb9\u6267\u884c<br>\u7236\u7c7b\u4e2d\u7684\u9759\u6001\u4ee3\u7801\u5757\u52a0\u8f7d<br>\u5b50\u7c7b\u9759\u6001\u6210\u5458\u53d8\u91cfnum2\u52a0\u8f7d<br>\u5b50\u7c7b\u4e2d\u7684\u9759\u6001\u4ee3\u7801\u5757<br>\u7c7b\u4e2d\u8c03\u7528\u5176\u4ed6\u7c7b\u65f6\uff0c\u5176\u4ed6\u7c7b\u7684\u9759\u6001\u51fd\u6570\u52a0\u8f7d  \/\/\u7236\u7c7b\u4e2d\u7684\u8c03\u7528\u5176\u4ed6\u7c7b \u5176\u5b83\u7c7b\u4e2d\u7684static{}\uff08\u53ea\u6267\u884c\u4e00\u6b21\uff09<br>\u7c7b\u4e2d\u8c03\u7528\u5176\u4ed6\u7c7b\u65f6\uff0c\u5176\u4ed6\u7c7b\u7684\u6784\u9020\u51fd\u6570\u52a0\u8f7d  \/\/\u5176\u5b83\u7c7b\u4e2d\u7684\u6784\u9020\u65b9\u6cd5<br>\u5b50\u7c7b\u6210\u5458\u53d8\u91cfnum\u52a0\u8f7d  \/\/\u6b64\u5904\u662f\u7236\u7c7b\u548c\u5b50\u7c7b\u7684\u540c\u540d\u6210\u5458\u51fd\u6570num \u5c31\u8fd1\u539f\u5219\u6267\u884c\u4e86\u5b50\u7c7b\u7684\uff08\u5927\u6982\uff0c\u6d4b\u8bd5\u4e0d\u540c\u540d\u6267\u884c\u7236\u7c7b\uff09<br>\u7236\u7c7b\u666e\u901a\u65b9\u6cd5\u5757\u52a0\u8f7d<br>\u7236\u7c7b\u4e2d\u7684\u6784\u9020\u51fd\u6570\u52a0\u8f7d<br>\u7c7b\u4e2d\u8c03\u7528\u5176\u4ed6\u7c7b\u65f6\uff0c\u5176\u4ed6\u7c7b\u7684\u6784\u9020\u51fd\u6570\u52a0\u8f7d  \/\/\u5176\u5b83\u7c7b\u4e2d\u7684\u6784\u9020\u65b9\u6cd5<br>\u5b50\u7c7b\u6210\u5458\u53d8\u91cfnum\u52a0\u8f7d<br>\u5b50\u7c7b\u666e\u901a\u65b9\u6cd5\u5757\u52a0\u8f7d<br>\u5b50\u7c7b\u4e2d\u7684\u6784\u9020\u51fd\u6570\u52a0\u8f7d<\/p>\n\n\n\n<p>\u7f51\u4e0a\u5173\u4e8e\u7236\u7c7b\u9759\u6001 \u3001\u666e\u901a\u4ee3\u7801\u5757\u3001\u6784\u9020\u51fd\u6570\u548c\u5b50\u7c7b\u4e2d\u7684\u8fd9\u4e9b \u7684\u6267\u884c\u987a\u5e8f\u6709\u5f88\u591a\uff0c\u6211\u4e3b\u8981\u662f\u9047\u5230\u4e86\u7236\u7c7b\u4e2d\u518d\u8c03\u7528\u5176\u4ed6\u7c7b\u8fdb\u884c\u5bf9\u8c61\u5b9e\u4f8b\u5316\uff0c\u8bb0\u5f55\u4e00\u4e0b\u987a\u5e8f\u7684\u5b66\u4e60\u3002<\/p>\n\n\n\n<p>\u53c2\u8003\u6587\u7ae0\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/m0_38110132\/article\/details\/78842873\">(8\u6761\u6d88\u606f) java\u5bf9\u8c61\u5b9e\u4f8b\u5316\u987a\u5e8f_\u6d6e\u751f\u4e00\u68a6-CSDN\u535a\u5ba2_java\u5b9e\u4f8b\u5316\u5bf9\u8c61\u6267\u884c\u987a\u5e8f<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3b\u8981\u8bb0\u5f55\u4e0bjava\u5b9e\u4f8b\u5316\u5bf9\u8c61\u3001\u9759\u6001\u4ee3\u7801\u5757\u7b49\u4ee3\u7801\u6267\u884c\u7684\u987a\u5e8f Java\u7a0b\u5e8f\u5728\u6267\u884c\u8fc7\u7a0b\u4e2d\uff0c\u7c7b\uff0c\u5bf9\u8c61\u4ee5\u53ca\u5b83\u4eec\u6210\u5458\u52a0\u8f7d\u3001 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-457","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.nokws.top\/index.php\/wp-json\/wp\/v2\/posts\/457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.nokws.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.nokws.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.nokws.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.nokws.top\/index.php\/wp-json\/wp\/v2\/comments?post=457"}],"version-history":[{"count":2,"href":"http:\/\/www.nokws.top\/index.php\/wp-json\/wp\/v2\/posts\/457\/revisions"}],"predecessor-version":[{"id":459,"href":"http:\/\/www.nokws.top\/index.php\/wp-json\/wp\/v2\/posts\/457\/revisions\/459"}],"wp:attachment":[{"href":"http:\/\/www.nokws.top\/index.php\/wp-json\/wp\/v2\/media?parent=457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.nokws.top\/index.php\/wp-json\/wp\/v2\/categories?post=457"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.nokws.top\/index.php\/wp-json\/wp\/v2\/tags?post=457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}