{"id":50337,"date":"2025-07-30T22:57:50","date_gmt":"2025-07-30T14:57:50","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/50337.html"},"modified":"2025-07-30T22:57:50","modified_gmt":"2025-07-30T14:57:50","slug":"%e5%a4%a7%e5%ad%a6%e7%94%9f%e5%85%a5%e9%97%a8%ef%bc%9astatic%e5%8f%8a%e5%85%b6%e6%98%93%e8%b8%a9%e5%9d%91%e7%9a%84%e7%82%b9","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/50337.html","title":{"rendered":"\u5927\u5b66\u751f\u5165\u95e8\uff1astatic\u53ca\u5176\u6613\u8e29\u5751\u7684\u70b9"},"content":{"rendered":"<p>\u00a0 \u00a0 \u00a0 \u00a0 static\u662f\u4ec0\u4e48&#xff1f;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color:#fe2c24\">static\u5173\u952e\u5b57<\/span>\u5c31\u50cf\u662f\u7a0b\u5e8f\u754c\u7684\u201c\u5171\u4eab\u5355\u8f66\u201d&#xff0c;\u5b83\u53ef\u4ee5\u8ba9\u67d0\u4e9b\u4e1c\u897f\u53d8\u6210\u201c\u516c\u5171\u8d22\u4ea7\u201d\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u2014\u2014\u62ff\u751f\u6d3b\u4e2d\u7684\u4f8b\u5b50\u6765\u8bf4&#xff0c;\u4f60\u4eec\u5bbf\u820d\u697c\u6709\u4e00\u53f0\u516c\u5171\u6d17\u8863\u673a&#xff08;static\u53d8\u91cf&#xff09;&#xff0c;\u6240\u6709\u5bbf\u820d\u6210\u5458&#xff08;\u5bf9\u8c61&#xff09;\u90fd\u53ef\u4ee5\u4f7f\u7528\u5b83&#xff0c;\u4e0d\u9700\u8981\u6bcf\u4e2a\u5bbf\u820d\u90fd\u4e70\u4e00\u53f0\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u2014\u2014\u6b63\u7ecf\u4e00\u70b9\u6765\u8bf4&#xff0c;static\u662fjava\u4e2d\u7684\u4e00\u4e2a\u5173\u952e\u5b57&#xff0c;<span style=\"color:#fe2c24\">\u7528\u4e8e\u8868\u793a\u67d0\u4e2a\u6210\u5458&#xff08;\u5c5e\u6027\/\u65b9\u6cd5&#xff09;\u5c5e\u4e8e\u7c7b\u672c\u8eab\u800c\u4e0d\u662f\u7c7b\u7684\u5b9e\u4f8b\u3002<\/span><\/p>\n<h2 style=\"background-color:transparent\"><span style=\"color:null\">\u4e00\u3001\u4e09\u5927\u7528\u6cd5<\/span><\/h2>\n<p>\u4e0b\u9762 \u4e09\u79cd\u7528\u6cd5 \u5149\u770b\u53ef\u80fd\u6709\u70b9\u5e72\u5df4&#xff0c;\u6709\u4e0d\u61c2\u7684\u5730\u65b9\u4e5f\u6ca1\u4e8b&#xff0c;\u4ecb\u7ecd\u5b8c\u6211\u4f1a\u4e00\u4e00\u89e3\u91ca\u8bf4\u660e\u3002<\/p>\n<h3><span style=\"color:null\">1\u3001\u4fee\u9970\u53d8\u91cf<\/span><\/h3>\n<p><span style=\"color:null\">\u4f5c\u7528&#xff1a;<\/span><\/p>\n<p><span style=\"color:null\">\u00a0 \u00a0 \u00a0 \u00a0 \u4fee\u9970\u6210\u5458\u53d8\u91cf&#xff0c;\u4f7f\u5176\u53d8\u6210\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff0c;\u9759\u6001\u6210\u5458\u53d8\u91cf\u5c5e\u4e8e\u7c7b\u3002<\/span><\/p>\n<p><span style=\"color:null\">\u7279\u6027&#xff1a;<\/span><\/p>\n<p><span style=\"color:null\">\u00a0 \u00a0 \u00a0 \u00a0 \u2460\u00a0\u8fd9\u4e2a\u7c7b\u4e0b\u9762\u7684\u6240\u6709\u5bf9\u8c61\u90fd\u53ef\u4ee5\u4f7f\u7528&#xff1b;<\/span><\/p>\n<p><span style=\"color:null\">\u00a0 \u00a0 \u00a0 \u00a0 \u2461 \u5bf9\u8c61\u80fd\u591f\u8bbf\u95ee\u9759\u6001\u6210\u5458\u5c5e\u6027&#xff0c;\u4e00\u822c\u5efa\u8bae&#xff0c;\u5bf9\u8c61\u505a\u67e5\u8be2&#xff1b;<\/span><\/p>\n<p><span style=\"color:null\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u7c7b\u4e5f\u80fd\u591f\u8bbf\u95ee\u9759\u6001\u6210\u5458\u5c5e\u6027&#xff0c;\u4e00\u822c\u5efa\u8bae&#xff0c;\u7c7b\u505a\u4fee\u6539&#xff1b;<\/span><\/p>\n<p><span style=\"color:null\">\u00a0 \u00a0 \u00a0 \u00a0 \u2462 \u5b83\u968f\u7740\u7c7b\u7684\u52a0\u8f7d\u800c\u52a0\u8f7d&#xff0c;\u5148\u4e8e\u5bf9\u8c61\u5b58\u5728&#xff1b;<\/span><\/p>\n<p><span style=\"color:null\">\u00a0 \u00a0 \u00a0 \u00a0 \u2463 \u5c3d\u91cf\u4e0d\u8981\u5728\u6784\u9020\u65b9\u6cd5\u4e2d\u8bbe\u7f6e\u9759\u6001\u6210\u5458\u53d8\u91cf\u7684\u503c&#xff0c;\u5426\u5219\u6bcf\u6b21\u65b0\u5efa\u5bf9\u8c61&#xff0c;\u8fd9\u4e2a\u503c\u90fd\u4f1a\u88ab\u91cd\u65b0\u8bbe\u7f6e\u3002<\/span><\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u597d&#xff0c;\u90a3\u4e48\u95ee\u9898\u6765\u4e86&#xff01;<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u4e3a\u4ec0\u4e48\u5efa\u8bae\u5bf9\u8c61\u505a\u67e5\u8be2&#xff0c;\u800c\u7c7b\u505a\u4fee\u6539\u5462&#xff1f;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"149\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730145746-688a32ea13517.png\" width=\"151\" \/><\/p>\n<p><span style=\"color:#fe2c24\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color:null\">\u9996\u5148\u6211\u4eec\u56de\u5fc6\u4e00\u4e0b\u524d\u9762\u8bf4\u7684&#xff0c;<\/span><span style=\"color:#fe2c24\">\u9759\u6001\u6210\u5458\u53d8\u91cf\u5c5e\u4e8e\u7c7b<\/span><\/p>\n<p><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u65e2\u7136\u5982\u6b64&#xff0c;\u6211\u4eec\u4e3a\u4ec0\u4e48\u8981\u591a\u6b64\u4e00\u4e3e\u7528\u201c <\/span><span style=\"color:#4da8ee\">\u5bf9\u8c61\u540d.\u9759\u6001\u6210\u5458\u53d8\u91cf<\/span><span style=\"color:null\"> \u201d\u5462&#xff1f;<\/span><\/p>\n<p><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u6240\u4ee5&#xff0c;\u4e3a\u4e86\u907f\u514d\u4fee\u6539\u6570\u636e\u65f6&#xff0c;\u8bef\u8ba4\u4e3a\u8fd9\u4e2a\u53d8\u91cf\u662f\u5c5e\u4e8e\u5bf9\u8c61\u7684<\/span><\/p>\n<p><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5728\u5bf9\u503c\u8fdb\u884c\u64cd\u4f5c\u7684\u65f6\u5019&#xff0c;\u4e00\u822c\u4f7f\u7528\u201c <\/span><span style=\"color:#4da8ee\">\u7c7b\u540d.\u9759\u6001\u6210\u5458\u53d8\u91cf <\/span><span style=\"color:null\">\u201d<\/span><\/p>\n<p><span style=\"color:null\">\u00a0 \u00a0 \u00a0 \u00a0 \u800c\u5728\u67e5\u8be2\u65f6&#xff0c;\u4e00\u822c\u662f\u8981\u67e5\u8be2\u5404\u4e2a\u5bf9\u8c61\u5355\u72ec\u7684\u72b6\u6001&#xff0c;\u8fd9\u4e2a\u65f6\u5019\u53ef\u4ee5\u4f7f\u7528\u201c<\/span><span style=\"color:#4da8ee\">\u5bf9\u8c61\u540d.\u9759\u6001\u6210\u5458\u53d8\u91cf<\/span><span style=\"color:null\"> <\/span><span style=\"color:null\">\u201d<\/span><\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u597d&#xff0c;\u90a3\u4e48\u95ee\u9898\u53c8\u6765\u4e86&#xff01;<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u9759\u6001\u6210\u5458\u53d8\u91cf\u662f\u600e\u4e48\u968f\u7740\u7c7b\u52a0\u8f7d\u800c\u52a0\u8f7d\u7684\u5462&#xff1f;\u5b83\u5148\u4e8e\u5bf9\u8c61\u53c8\u6709\u4ec0\u4e48\u4f5c\u7528\u5417&#xff1f;<\/span><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8fd9\u4e2a\u95ee\u9898\u6211\u4eec\u653e\u5230\u540e\u9762&#xff0c;\u8ba8\u8bba\u5b8c\u9759\u6001\u65b9\u6cd5\u548c\u9759\u6001\u4ee3\u7801\u5757\u518d\u6765\u8be6\u7ec6\u89e3\u91ca\u00a0<\/p>\n<\/p>\n<h3>2\u3001\u4fee\u9970\u65b9\u6cd5<\/h3>\n<p>\u4f5c\u7528&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u540c\u6837\u5c06\u6210\u5458\u65b9\u6cd5\u4fee\u9970\u4e3a\u9759\u6001&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u7c7b\u540d\u76f4\u63a5\u8c03\u7528&#xff0c;\u4e3b\u8981\u7528\u6765\u64cd\u4f5cstatic\u6210\u5458&#xff08;\u5c5e\u6027\/\u65b9\u6cd5&#xff09;<\/p>\n<p>\u7279\u6027&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0\u2460 static\u65b9\u6cd5\u53ea\u80fd\u8bbf\u95eestatic\u6210\u5458&#xff08;\u5c5e\u6027\/\u65b9\u6cd5&#xff09;&#xff1b;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0\u2461 \u4e5f\u53ef\u4ee5\u7528\u5bf9\u8c61\u6765\u8c03\u7528&#xff0c;\u4f46\u662f\u63a8\u8350\u7528\u7c7b\u540d&#xff1b;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0\u2462 static\u65b9\u6cd5\u4e2d\u8c03\u7528\u7684\u65b9\u6cd5\u53ea\u80fd\u662fstatic\u65b9\u6cd5&#xff1b;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0\u2463 static\u65b9\u6cd5\u4e2d\u6ca1\u6709 this \u548c super \u5173\u952e\u5b57&#xff1b;<\/p>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"140\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730145746-688a32ea4c3a8.png\" width=\"155\" \/><\/p>\n<p><span style=\"color:#fe2c24\">\u4e3a\u4ec0\u4e48static\u65b9\u6cd5\u4e0d\u53ef\u4ee5\u8bbf\u95ee\u975estatic\u6210\u5458&#xff0c;\u800c\u975estatic\u65b9\u6cd5\u53ef\u4ee5\u8bbf\u95eestatic\u6210\u5458\u5462&#xff1f;<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"color:null\">\u524d\u9762\u63d0\u5230\u4e86&#xff1a;\u9759\u6001\u6210\u5458\u968f\u7740\u7c7b\u7684\u52a0\u8f7d\u800c\u52a0\u8f7d&#xff0c;\u5148\u4e8e\u5bf9\u8c61\u5b58\u5728<\/span><\/p>\n<p><span style=\"color:null\">\u00a0 \u00a0 \u00a0 \u00a0 \u8fd9\u53e5\u8bdd\u5148\u7528\u5728\u8fd9\u91cc&#xff0c;\u7b49\u4f1a\u6211\u4eec\u518d\u89e3\u91ca<\/span><\/p>\n<p><span style=\"color:null\">\u00a0 \u00a0 \u00a0 \u00a0 \u90a3\u4e48\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u53ea\u8981\u7c7b\u5b58\u5728&#xff0c;\u9759\u6001\u6210\u5458\u5982\u679c\u5b9a\u4e49\u4e86\u5c31\u4f1a\u8ddf\u7740\u5b58\u5728<\/span><\/p>\n<p><span style=\"color:null\">\u00a0 \u00a0 \u00a0 \u00a0 \u6b64\u65f6\u806a\u660e\u7684\u540c\u5b66\u5df2\u7ecf\u53d1\u73b0\u4e86<\/span><\/p>\n<p><span style=\"color:null\">\u00a0 \u00a0 \u00a0 \u00a0 \u975e static \u65b9\u6cd5\u8bbf\u95ee\u65f6&#xff0c;static \u6210\u5458\u4e00\u5b9a\u5b58\u5728&#xff1b;<\/span><\/p>\n<p><span style=\"color:null\">\u00a0 \u00a0 \u00a0 \u00a0 \u800c static \u65b9\u6cd5\u8bbf\u95ee\u65f6&#xff0c;\u5bf9\u8c61 \u4e0d\u4e00\u5b9a\u88ab\u521b\u5efa\u4e86\u3002<\/span><\/p>\n<p><span style=\"color:null\">\u00a0 \u00a0 \u00a0 \u00a0 \u6240\u4ee5 static \u65b9\u6cd5\u4e0d\u80fd\u8bbf\u95ee \u975estatic \u7684\u6210\u5458&#xff0c;\u4e0d\u5b58\u5728\u8fd8\u8bbf\u95ee\u4e2ader<\/span><\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u7b2c\u4e8c\u4e2a\u95ee\u9898&#xff0c;\u4e3a\u4ec0\u4e48static\u65b9\u6cd5\u4e2d\u6ca1\u6709 this \u5173\u952e\u5b57&#xff1f;<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color:null\">\u8fd9\u5c31\u4e0d\u5f97\u4e0d\u63d0\u5230\u5185\u5b58\u56fe\u4e86&#xff0c;\u6211\u4eec\u901a\u8fc7\u5185\u5b58\u56fe\u770b\u4e00\u4e0b this \u662f\u4ec0\u4e48\u4f5c\u7528&#xff0c;\u6765\u5427\u5c55\u793a&#xff1a;<\/span><\/p>\n<p>public static void main(String[] args){<br \/>\n    Student stu1 &#061; new Student(&#034;jack&#034;,21);<br \/>\n    stu1.sayHello();<\/p>\n<p>    Student stu2 &#061; new Student(&#034;Tom&#034;.18);<br \/>\n    stu2.sayHello();<br \/>\n}<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"504\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730145746-688a32ea83e21.png\" width=\"631\" \/><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u901a\u8fc7\u8fd9\u4e2a\u56fe\u4e0d\u96be\u53d1\u73b0&#xff0c;\u6b64\u65f6 this \u7684\u4f5c\u7528\u662f\u4ee3\u8868\u5f53\u524d\u5bf9\u8c61\u5b9e\u4f8b\u7684\u5f15\u7528<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u65e2\u7136\u6211\u4eecstatic\u5c5e\u4e8e\u7c7b&#xff0c;\u90fd\u4e0d\u9700\u8981\u5bf9\u8c61&#xff0c;\u6ca1\u6709\u5bf9\u8c61\u54ea\u6765\u7684 this&#xff1f;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0super \u5462\u4e5f\u662f\u5927\u540c\u5c0f\u5f02&#xff0c;super\u4ee3\u8868\u7684\u662f\u5f53\u524d\u5bf9\u8c61\u7684\u7236\u7c7b\u5b9e\u4f8b\u7684\u5f15\u7528<\/p>\n<p>\u90a3\u4e48 this \u548c super \u7684\u8be6\u7ec6\u529f\u80fd\u6709\u54ea\u4e9b\u5462&#xff1f;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"150\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730145747-688a32eb1f818.png\" width=\"149\" \/><\/p>\n<p>\u5185\u4e2a&#xff0c;this \u6211\u6682\u65f6\u8fd8\u6ca1\u5199\u54c8&#xff0c;\u7b49\u6211\u5199\u5b8c\u628a\u94fe\u63a5\u653e\u5230\u8fd9\u91cc~<\/p>\n<p>super \u5728\u4e0b\u6587\u8bb2\u52a0\u8f7d\u987a\u5e8f\u65f6\u4f1a\u63d0\u5230<\/p>\n<\/p>\n<h3>3\u3001\u4fee\u9970\u4ee3\u7801\u5757<\/h3>\n<p>static{<br \/>\n    \/\/\u4ee3\u7801<br \/>\n}<\/p>\n<p>\u7279\u6027&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u540c\u6837\u662f\u7c7b\u52a0\u8f7d\u7684\u65f6\u5019\u6267\u884c<\/p>\n<\/p>\n<p>\u8fd9\u4e2a\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684&#xff0c;\u6211\u4eec\u76f4\u63a5\u8001\u89c4\u77e9\u5427<\/p>\n<p><span style=\"color:#fe2c24\">\u4ec0\u4e48\u662f\u4ee3\u7801\u5757&#xff1f;<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color:null\">\u4ee3\u7801\u5757\u5176\u5b9e\u5c31\u662f\u7528 { } \u62ec\u8d77\u6765\u7684\u4ee3\u7801<\/span><\/p>\n<p>\u53ef\u4ee5\u5206\u4e3a\u4e09\u7c7b&#xff1a;<\/p>\n<p>1\u3001\u5c40\u90e8\u4ee3\u7801\u5757<\/p>\n<p>\u65b9\u6cd5\u4e2d\u7684\u201c\u4e34\u65f6\u5de5\u201d&#xff0c;\u7528\u5b8c\u5c31\u6d88\u5931<\/p>\n<p>\u6743\u9650\u4fee\u9970\u7b26 \u6570\u636e\u7c7b\u578b \u65b9\u6cd5\u540d&#xff08;\u5f62\u53c2\u5217\u8868&#xff09;{<br \/>\n    \/\/\u5c40\u90e8\u4ee3\u7801\u5757<br \/>\n}<\/p>\n<p>\u5b9a\u4e49\u4f4d\u7f6e&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7c7b\u7684\u65b9\u6cd5\u4e2d\u5b9a\u4e49<\/p>\n<p>\u4f5c\u7528&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7528\u4e8e\u9650\u5b9a\u53d8\u91cf\u7684\u751f\u547d\u5468\u671f&#xff0c;\u4f7f\u5176\u5c3d\u65e9\u91ca\u653e&#xff0c;\u63d0\u9ad8\u6808\u7a7a\u95f4\u7684\u5185\u5b58\u5229\u7528\u7387<\/p>\n<p>2\u3001\u6784\u9020\u4ee3\u7801\u5757&#xff08;\u533f\u540d\u4ee3\u7801\u5757&#xff09;<\/p>\n<p>\u6bcf\u4e2a\u5bf9\u8c61\u521b\u5efa\u524d\u7684\u201c\u70ed\u8eab\u8fd0\u52a8\u201d&#xff0c;\u6ca1\u540d\u5b57\u6240\u4ee5\u53c8\u53eb\u533f\u540d\u4ee3\u7801\u5757<\/p>\n<p>{<br \/>\n    \/\/\u6784\u9020\u4ee3\u7801\u5757<br \/>\n}<\/p>\n<p>\u5b9a\u4e49\u4f4d\u7f6e&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7c7b\u4e2d&#xff0c;\u65b9\u6cd5\u5916<\/p>\n<p>\u4f5c\u7528&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u6bcf\u6b21\u6784\u9020\u65b9\u6cd5\u6267\u884c\u524d&#xff0c;\u90fd\u4f1a\u5148\u6267\u884c\u8be5\u4ee3\u7801\u4e2d\u7684\u4ee3\u7801\u5757<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5982\u679c\u6bcf\u4e2a\u6784\u9020\u65b9\u6cd5\u4e2d\u90fd\u6709\u76f8\u540c\u7684\u65b9\u6cd5&#xff0c;\u53ef\u4ee5\u62bd\u53d6\u51fa\u6765\u653e\u5728\u6784\u9020\u4ee3\u7801\u4e2d<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u63d0\u9ad8\u4ee3\u7801\u590d\u7528\u7387<\/p>\n<p>3\u3001\u9759\u6001\u4ee3\u7801\u5757<\/p>\n<p>\u7c7b\u52a0\u8f7d\u65f6\u7684\u201c\u5f00\u673a\u81ea\u68c0\u201d&#xff0c;\u53ea\u6267\u884c\u4e00\u6b21<\/p>\n<p>static{<br \/>\n    \/\/\u9759\u6001\u4ee3\u7801\u5757<br \/>\n}<\/p>\n<p>\u5b9a\u4e49\u4f4d\u7f6e&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7c7b\u4e2d&#xff0c;\u65b9\u6cd5\u5916<\/p>\n<p>\u4f5c\u7528&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u521d\u59cb\u5316\u9759\u6001\u53d8\u91cf\u6216\u8005\u6267\u884c\u53ea\u9700\u8981\u6267\u884c\u4e00\u6b21\u7684\u4ee3\u7801<\/p>\n<\/p>\n<h2>\u4e8c\u3001\u9759\u6001\u6210\u5458\u53d8\u91cf\u548c\u975e\u9759\u6001\u6210\u5458\u53d8\u91cf\u7684\u533a\u522b<\/h2>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u4ece\u4e0d\u540c\u89d2\u5ea6\u5206\u6790\u4e00\u4e0b\u8fd9\u4fe9 \u201c\u53cc\u80de\u80ce\u201d \u7684\u5bf9\u6bd4<\/p>\n<h3>1\u3001\u5b58\u50a8\u4f4d\u7f6e<\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u5b58\u50a8\u5728\u65b9\u6cd5\u533a\u4e2d\u7684\u9759\u6001\u533a<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u975e\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u5b58\u50a8\u5728\u5806\u5185\u5b58\u7684\u5bf9\u8c61\u5185<\/span><\/p>\n<p>public class StorageExample {<br \/>\n    \/\/ \u9759\u6001\u6210\u5458\u53d8\u91cf &#8211; \u5b58\u50a8\u5728\u65b9\u6cd5\u533a\u7684\u9759\u6001\u533a<br \/>\n    static int staticVar &#061; 10;<\/p>\n<p>    \/\/ \u975e\u9759\u6001\u6210\u5458\u53d8\u91cf &#8211; \u5b58\u50a8\u5728\u5806\u5185\u5b58\u7684\u5bf9\u8c61\u5185<br \/>\n    int instanceVar &#061; 20;<\/p>\n<p>    public static void main(String[] args) {<br \/>\n        StorageExample obj1 &#061; new StorageExample();<br \/>\n        StorageExample obj2 &#061; new StorageExample();<\/p>\n<p>        \/\/ \u9759\u6001\u53d8\u91cf\u88ab\u6240\u6709\u5b9e\u4f8b\u5171\u4eab<br \/>\n        System.out.println(&#034;obj1.staticVar: &#034; &#043; obj1.staticVar); \/\/ 10<br \/>\n        System.out.println(&#034;obj2.staticVar: &#034; &#043; obj2.staticVar); \/\/ 10<\/p>\n<p>        \/\/ \u4fee\u6539\u9759\u6001\u53d8\u91cf\u5f71\u54cd\u6240\u6709\u5b9e\u4f8b<br \/>\n        StorageExample.staticVar &#061; 30;<br \/>\n        System.out.println(&#034;obj1.staticVar: &#034; &#043; obj1.staticVar); \/\/ 30<br \/>\n        System.out.println(&#034;obj2.staticVar: &#034; &#043; obj2.staticVar); \/\/ 30<\/p>\n<p>        \/\/ \u975e\u9759\u6001\u53d8\u91cf\u6bcf\u4e2a\u5b9e\u4f8b\u72ec\u7acb\u62e5\u6709<br \/>\n        obj1.instanceVar &#061; 40;<br \/>\n        obj2.instanceVar &#061; 50;<br \/>\n        System.out.println(&#034;obj1.instanceVar: &#034; &#043; obj1.instanceVar); \/\/ 40<br \/>\n        System.out.println(&#034;obj2.instanceVar: &#034; &#043; obj2.instanceVar); \/\/ 50<br \/>\n    }<br \/>\n}<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"580\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730145747-688a32eb5b24d.png\" width=\"959\" \/><\/p>\n<h3>2\u3001\u751f\u547d\u5468\u671f<\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u4ece\u7c7b\u52a0\u8f7d\u5f00\u59cb\u5230\u7a0b\u5e8f\u7ed3\u675f<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u975e\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u4ece\u5bf9\u8c61\u521b\u5efa\u5230\u5bf9\u8c61\u88ab\u5783\u573e\u56de\u6536\u5668\u56de\u6536<\/span><\/p>\n<h3 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:null\">3\u3001\u51fa\u73b0\u987a\u5e8f<\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u968f\u7740\u7c7b\u52a0\u8f7d\u800c\u52a0\u8f7d\u51fa\u73b0<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u975e\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u5bf9\u8c61\u5b9e\u4f8b\u5316\u65f6\u51fa\u73b0<\/span><\/p>\n<h3><span style=\"color:null\">4\u3001\u8c03\u7528\u65b9\u5f0f<\/span><\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u901a\u8fc7\u7c7b\u540d\u76f4\u63a5\u8c03\u7528<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u975e\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u901a\u8fc7\u5bf9\u8c61\u5b9e\u4f8b\u8c03\u7528<\/span><\/p>\n<h3>5\u3001\u521d\u59cb\u5316\u65f6\u673a<\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u7d2f\u52a0\u8f7d\u65f6\u521d\u59cb\u5316<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u975e\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u5bf9\u8c61\u521b\u5efa\u65f6\u521d\u59cb\u5316<\/span><\/p>\n<h3>6\u3001\u5185\u5b58\u5360\u7528<\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u6bcf\u4e2a\u7c7b\u53ea\u6709\u4e00\u4efd<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u975e\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u6bcf\u4e2a\u5bf9\u8c61\u90fd\u6709\u4e00\u4efd<\/span><\/p>\n<h3>7\u3001\u5171\u4eab<\/h3>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u540c\u4e00\u4e2a\u7c7b\u7684\u6240\u6709\u5bf9\u8c61\u5171\u4eab\u4e00\u4efd\u6570\u636e<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u975e\u9759\u6001\u6210\u5458\u53d8\u91cf&#xff1a;\u6bcf\u4e2a\u5bf9\u8c61\u6709\u72ec\u7acb\u7684\u6570\u636e<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u8fd9\u4e9b\u6bd4\u8f83\u5bb9\u6613\u7406\u89e3&#xff0c;\u8fd9\u91cc\u5c31\u5077\u4e2a\u61d2\u4e0d\u89e3\u91ca\u5566<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u6211\u4eec\u7740\u91cd\u8ba8\u8bba\u540e\u9762\u7684\u91cd\u70b9<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<h2 style=\"background-color:transparent;margin-left:0.0001pt;margin-right:0px;text-align:justify\">\u4e09\u3001static \u65b9\u6cd5\u548c \u975estatic \u65b9\u6cd5\u7684\u533a\u522b&#xff0c;\u4ec0\u4e48\u60c5\u51b5\u4e0b\u7528static\u65b9\u6cd5&#xff1f;<\/h2>\n<p>\u533a\u522b&#xff1a;<\/p>\n<p>\u9664\u4e86\u524d\u9762\u63d0\u5230\u7684\u4e92\u76f8\u80fd\u5426\u8bbf\u95ee\u3001\u80fd\u5426\u4f7f\u7528 this \u548c super \u4e4b\u5916&#xff0c;\u8fd8\u6709\u4ee5\u4e0b\u533a\u522b&#xff1a;<\/p>\n<p><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0static \u65b9\u6cd5\u548c \u975estatic \u65b9\u6cd5\u867d\u7136\u5b57\u8282\u7801\u90fd\u5b58\u50a8\u5728\u65b9\u6cd5\u533a<\/span><\/p>\n<p><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4f46\u662f\u5728\u8fd0\u884c\u65f6&#xff0c;\u975estatic \u65b9\u6cd5\u4e0e \u5806\u5185\u5b58 \u6709\u7740\u5bc6\u4e0d\u53ef\u5206\u7684\u8054\u7cfb\u3002<\/span><\/p>\n<p><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u539f\u56e0\u5728\u4e8e&#xff0c;static \u65b9\u6cd5\u53ef\u4ee5\u88ab\u7c7b\u76f4\u63a5\u8c03\u7528&#xff0c;\u800c \u975estatic \u65b9\u6cd5\u9700\u8981\u5bf9\u8c61\u5b9e\u4f8b\u8c03\u7528<\/span><\/p>\n<p><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u975estatic \u65b9\u6cd5\u64cd\u4f5c\u7684\u6210\u5458\u53d8\u91cf\u5b58\u50a8\u5728\u5bf9\u8c61\u5b9e\u4f8b\u4e2d&#xff0c;\u800c \u5bf9\u8c61\u5b9e\u4f8b \u5b58\u50a8\u5728\u5806\u5185\u5b58\u4e2d<\/span><\/p>\n<p><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u6240\u4ee5\u9700\u8981 this \u6307\u9488\u9690\u5f0f\u8bbf\u95ee\u5806\u5185\u5b58\u4e2d\u7684\u5bf9\u8c61<\/span><\/p>\n<\/p>\n<p><span style=\"color:null\">\u4f7f\u7528&#xff1a;<\/span><\/p>\n<p><span style=\"color:null\">1\u3001\u5de5\u5177\u7c7b\u91cc\u7684\u65b9\u6cd5<\/span><\/p>\n<p><span style=\"color:null\">2\u3001\u82e5\u65b9\u6cd5\u53ea\u9700\u8981\u8bbf\u95ee\u9759\u6001\u6210\u5458&#xff0c;\u53ef\u4ee5\u751f\u547d static \u9632\u6b62\u5197\u4f59\u7684\u5bf9\u8c61\u521b\u5efa<\/span><\/p>\n<p><span style=\"color:null\">3\u3001\u5b9e\u73b0\u5355\u4f8b\u6a21\u5f0f<\/span><\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u8bf6<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u4ec0\u4e48\u662f\u5355\u4f8b\u6a21\u5f0f&#xff1f;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"150\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730145748-688a32ec7ee73.png\" width=\"151\" \/><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5355\u4f8b\u6a21\u5f0f\u5c31\u662f\u4e00\u4e2a\u7c7b\u4e2d\u53ea\u6709\u4e00\u4e2a\u5b9e\u4f8b<span style=\"color:#ad720d\">&#xff08;\u5c31\u50cf\u5730\u7403\u53ea\u6709\u4e00\u4e2a\u592a\u9633&#xff09;<\/span>&#xff0c;\u5e76\u4e14\u79c1\u6709\u5316\u6784\u9020\u65b9\u6cd5&#xff0c;\u9632\u6b62\u5916\u90e8 new \u64cd\u4f5c&#xff0c;\u540c\u65f6\u63d0\u4f9b\u4e00\u4e2a\u5168\u5c40\u53ef\u4ee5\u8bbf\u95ee\u8be5\u5b9e\u4f8b\u7684\u65b9\u6cd5&#xff0c;\u76f4\u63a5\u4e0a\u4ee3\u7801&#xff1a;<\/p>\n<p>public class Singleton {<br \/>\n    \/\/ 1. \u9759\u6001\u53d8\u91cf\u5b58\u50a8\u552f\u4e00\u5b9e\u4f8b&#xff08;\u7c7b\u52a0\u8f7d\u65f6\u7acb\u5373\u521d\u59cb\u5316&#xff09;<br \/>\n    private static final Singleton instance &#061; new Singleton();<\/p>\n<p>    \/\/ 2. \u79c1\u6709\u6784\u9020\u5668\u963b\u65ad\u5916\u90e8\u5b9e\u4f8b\u5316<br \/>\n    private Singleton() {<br \/>\n        System.out.println(&#034;Singleton instance created&#034;);<br \/>\n    }<\/p>\n<p>    \/\/ 3. \u5168\u5c40\u8bbf\u95ee\u70b9<br \/>\n    public static Singleton getInstance() {<br \/>\n        return instance;<br \/>\n    }<\/p>\n<p>    \/\/ \u793a\u4f8b\u65b9\u6cd5<br \/>\n    public void showMessage() {<br \/>\n        System.out.println(&#034;Hello from Singleton!&#034;);<br \/>\n    }<br \/>\n}<\/p>\n<p>\u6ce8\u610f&#xff0c;\u8fd9\u91cc\u7684\u6570\u636e\u7c7b\u578b\u5c31\u662f\u6211\u4eec\u521b\u5efa\u7684\u7c7b&#xff0c;\u8fd4\u56de\u503c\u5c31\u662f\u5bf9\u8c61&#xff1a;<\/p>\n<p>public static Singleton getInstance() {<br \/>\n        return instance;<br \/>\n    }<\/p>\n<h2>\u56db\u3001\u80fd\u5426\u7ee7\u627f static \u6210\u5458\u53d8\u91cf\u6216\u65b9\u6cd5&#xff1f;<\/h2>\n<p><span style=\"color:#fe2c24\">\u5728\u6743\u9650\u5141\u8bb8\u7684\u60c5\u51b5\u4e0b\u662f\u53ef\u4ee5\u7684&#xff08;\u6bd4\u5982 private \u4e0d\u53ef\u4ee5&#xff09;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#0000ff\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color:null\">\u7ee7\u627f\u540e&#xff0c;\u5b50\u7c7b\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u7236\u7c7b\u7684\u9759\u6001\u6210\u5458\u53d8\u91cf\u548c\u65b9\u6cd5&#xff0c;\u4f46\u5b50\u7c7b\u65e0\u6cd5\u8986\u76d6\u7236\u7c7b\u7684\u9759\u6001\u65b9\u6cd5&#xff0c;\u53ea\u80fd\u9690\u85cf\u3002<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4ec0\u4e48\u610f\u601d\u5462&#xff1f;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5982\u679c\u5b50\u7c7b \u6ca1\u5199 \u548c\u7236\u7c7b\u540c\u540d\u7684\u9759\u6001\u6210\u5458&#xff0c;\u90a3\u4e48 \u5b50\u7c7b\u540d.\u9759\u6001\u6210\u5458\u00a0\u6216 \u7236\u7c7b\u540d.\u9759\u6001\u6210\u5458\u00a0\u662f\u7b49\u6548\u7684&#xff1b;\u5982\u679c\u5199\u4e86\u540c\u540d\u9759\u6001\u6210\u5458&#xff0c;\u90a3\u4e48 \u5b50\u7c7b\u540d.\u9759\u6001\u6210\u5458\u00a0\u8c03\u7528\u7684\u5c31\u662f\u5b50\u7c7b\u7684&#xff0c;\u7236\u7c7b\u540d.\u9759\u6001\u6210\u5458\u00a0\u8c03\u7528\u7684\u5c31\u662f\u7236\u7c7b\u7684<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5b50\u7c7b\u4e0e\u7236\u7c7b\u5171\u4eab\u540c\u4e00\u4e2a\u9759\u6001\u6210\u5458\u5185\u5b58\u7a7a\u95f4&#xff0c;\u4fee\u6539\u4e00\u5904\u5168\u5c40\u751f\u6548<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<h2 style=\"margin-left:0.0001pt;margin-right:0px;text-align:justify\"><span style=\"color:null\">\u4e94\u3001\u8fd0\u884c\u987a\u5e8f<\/span><\/h2>\n<p><span style=\"color:null\">\u00a0 \u00a0 \u00a0 \u00a0 \u524d\u9762\u6211\u4eec\u63d0\u5230\u4e86\u5f88\u591a\u6982\u5ff5&#xff0c;\u6bd4\u5982\u8bf4 \u7c7b\u52a0\u8f7d\u3001\u5404\u79cd\u4ee3\u7801\u5757\u3001\u9759\u6001\u65b9\u6cd5\u7b49\u7b49<\/span><\/p>\n<p><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color:#fe2c24\">\u90a3\u4e48\u5b83\u4eec\u7684\u6267\u884c\u987a\u5e8f\u662f\u4ec0\u4e48\u5462&#xff1f;\u6211\u4eec\u5148\u6765\u770b\u4e09\u4e2a\u6848\u4f8b&#xff1a;<\/span><\/p>\n<p>public class T1 {<br \/>\n    public T1() {<br \/>\n        System.out.println(&#034;\u6784\u9020\u5668&#034;);<br \/>\n    }<br \/>\n    public void info() {<br \/>\n        System.out.println(&#034;info&#034;);<br \/>\n    }<br \/>\n    static {<br \/>\n        System.out.println(&#034;test static 1&#034;);<br \/>\n    }<br \/>\n    public static void main(String[] args) {<br \/>\n        new T1().info();<br \/>\n    }<br \/>\n    {<br \/>\n        System.out.println(&#034;\u4ee3\u7801\u5757&#034;);<br \/>\n    }<br \/>\n    static {<br \/>\n        System.out.println(&#034;test static 2&#034;);<br \/>\n    }<br \/>\n}<\/p>\n<p>\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"155\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730145748-688a32eca0219.png\" width=\"142\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u7ed3\u679c&#xff1a;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">test static 1<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">test static 2<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u4ee3\u7801\u5757<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u6784\u9020\u5668<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">Info<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u539f\u56e0&#xff1a;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color:null\">\u9996\u5148\u8fdb\u5165main&#xff0c;\u9700\u8981\u521b\u5efaTest\u5bf9\u8c61&#xff0c;\u7136\u540e\u8c03\u7528Test\u7684\u65b9\u6cd5&#xff0c;\u68c0\u67e5\u662f\u5426\u52a0\u8f7dTest\u7c7b&#xff0c;\u53d1\u73b0\u6ca1\u6709&#xff0c;\u5f00\u59cb\u52a0\u8f7dTest\u7c7b&#xff1a;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7531\u4e8e\u6ca1\u6709\u9759\u6001\u6210\u5458\u521d\u59cb\u5316&#xff0c;\u76f4\u63a5\u52a0\u8f7d\u4e24\u4e2a\u9759\u6001\u4ee3\u7801\u5757&#xff0c;\u7136\u540e\u5f00\u59cb\u521b\u5efa\u5bf9\u8c61&#xff0c;\u6784\u9020\u4ee3\u7801\u5757\u6267\u884c\u987a\u5e8f\u5728\u6784\u9020\u65b9\u6cd5\u4e4b\u524d&#xff0c;\u6700\u540e\u8c03\u7528info\u65b9\u6cd5<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p>public class T2 {<br \/>\n    public static void main(String[] args) {<br \/>\n        Child child &#061; new Child();<br \/>\n    }<br \/>\n} <\/p>\n<p>class Parent {<br \/>\n    static {<br \/>\n        System.out.println(&#034;\u9759\u6001\u4ee3\u7801\u5757Parent&#034;);<br \/>\n    }<br \/>\n    {<br \/>\n        System.out.println(&#034;\u6784\u9020\u4ee3\u7801\u5757Parent&#034;);<br \/>\n    }<br \/>\n    public Parent() {<br \/>\n        System.out.println(&#034;\u6784\u9020\u65b9\u6cd5Parent&#034;);<br \/>\n    }<br \/>\n} <\/p>\n<p>class Child extends Parent {<br \/>\n    static {<br \/>\n        System.out.println(&#034;\u9759\u6001\u4ee3\u7801\u5757Child&#034;);<br \/>\n    }<br \/>\n    {<br \/>\n        System.out.println(&#034;\u6784\u9020\u4ee3\u7801\u5757Child&#034;);<br \/>\n    }<br \/>\n    public Child() {<br \/>\n        System.out.println(&#034;\u6784\u9020\u65b9\u6cd5Child&#034;);<br \/>\n    }<br \/>\n}<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"202\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730145748-688a32ecdd1a6.png\" width=\"156\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u7ed3\u679c&#xff1a;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u9759\u6001\u4ee3\u7801\u5757Parent<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u9759\u6001\u4ee3\u7801\u5757Child<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u6784\u9020\u4ee3\u7801\u5757Parent<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u6784\u9020\u65b9\u6cd5Parent<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u6784\u9020\u4ee3\u7801\u5757Child<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u6784\u9020\u65b9\u6cd5Child<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u539f\u56e0&#xff1a;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u5728\u5b50\u7c7b\u7684\u6784\u9020\u65b9\u6cd5\u4e2d&#xff0c;\u7f16\u8bd1\u5668\u81ea\u52a8\u6dfb\u52a0\u4e86\u65e0\u53c2\u7684super()\u8c03\u7528<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"150\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730145749-688a32ed0d888.png\" width=\"150\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#ad720d\">\u90fd\u770b\u5230\u8fd9\u4e86&#xff0c;\u7ed9\u5b69\u5b50\u70b9\u4e2a\u8d5e\u5427~<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#fe2c24\">super\u5173\u952e\u5b57&#xff1a;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u4f5c\u7528&#xff1a;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7528\u4e8e\u5f15\u7528\u5f53\u524d\u5bf9\u8c61\u7684\u76f4\u63a5\u7236\u7c7b\u5b9e\u4f8b<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">1\u3001\u8c03\u7528\u7236\u7c7b\u7684\u6784\u9020\u65b9\u6cd5<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u8bed\u6cd5&#xff1a;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0super() \u6216 super(\u53c2\u6570\u5217\u8868)<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5fc5\u987b\u5728\u5b50\u7c7b\u6784\u9020\u65b9\u6cd5\u7684\u7b2c\u4e00\u884c<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5982\u679c\u5b50\u7c7b\u6784\u9020\u65b9\u6cd5\u4e2d\u6ca1\u6709\u663e\u793a\u8c03\u7528 super() \u6216\u8005 this() &#xff0c;\u7f16\u8bd1\u5668\u4f1a\u81ea\u52a8\u6dfb\u52a0\u65e0\u53c2\u7684super()\u8c03\u7528\u3002\u8c03\u7528 this() \u4e4b\u540e&#xff0c;\u6307\u5411\u672c\u7c7b\u53e6\u4e00\u4e2a\u6784\u9020\u65b9\u6cd5&#xff0c;<\/span><span style=\"color:#fe2c24\">\u4e0d\u8bba\u8fd9\u4e2a\u8c03\u7528\u94fe\u5f0f\u6709\u591a\u957f&#xff0c;\u6700\u7ec8\u90fd\u4f1a\u8c03\u7528\u5230super()\u3002<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">2\u3001\u8bbf\u95ee\u7236\u7c7b\u6210\u5458\u53d8\u91cf<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5f53\u5b50\u7c7b\u548c\u7236\u7c7b\u6709\u540c\u540d\u6210\u5458\u53d8\u91cf\u65f6&#xff1a;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0super.\u53d8\u91cf\u540d \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/\u8c03\u7528\u7236\u7c7b\u7684\u6210\u5458\u53d8\u91cf<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">3\u3001\u8c03\u7528\u7236\u7c7b\u6210\u5458\u65b9\u6cd5<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5f53\u5b50\u7c7b\u91cd\u5199\u4e86\u7236\u7c7b\u7684\u65b9\u6cd5&#xff0c;\u4f46\u4ecd\u60f3\u8c03\u7528\u7236\u7c7b\u7684\u539f\u65b9\u6cd5&#xff1a;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0super.\u65b9\u6cd5\u540d\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/\u8c03\u7528\u7236\u7c7b\u65b9\u6cd5<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p>class B {<br \/>\n    public static B b &#061; new B();<br \/>\n    public static B b2 &#061; new B();<br \/>\n    {<br \/>\n        System.out.println(&#034;\u6784\u9020\u5757&#034;);<br \/>\n    }<br \/>\n    static {<br \/>\n        System.out.println(&#034;\u9759\u6001\u5757&#034;);<br \/>\n    }<br \/>\n}<br \/>\npublic class T3 {<br \/>\n    public static void main(String[] args) {<br \/>\n        B b &#061; new B();<br \/>\n    }<br \/>\n}<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u7ed3\u679c&#xff1a;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u6784\u9020\u5757<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u6784\u9020\u5757<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u9759\u6001\u5757<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:#4da8ee\">\u6784\u9020\u5757<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u539f\u56e0&#xff1a;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u6700\u5f00\u59cb\u8fdb\u5165main\u4e4b\u540e\u53d1\u73b0\u9700\u8981\u521b\u5efa\u5bf9\u8c61&#xff0c;\u7136\u540e\u68c0\u67e5B\u7c7b\u662f\u5426\u52a0\u8f7d&#xff0c;\u53d1\u73b0\u6ca1\u6709\u52a0\u8f7d\u4e8e\u662f\u5f00\u59cb\u52a0\u8f7dB\u7c7b&#xff1a;<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u9759\u6001\u4ee3\u7801\u5757\u9700\u8981\u5728\u9759\u6001\u6210\u5458\u53d8\u91cf\u521d\u59cb\u5316\u4e4b\u540e\u6267\u884c&#xff0c;\u800c<\/span><span style=\"color:#fe2c24\">\u6b64\u65f6\u9759\u6001\u6210\u5458\u53d8\u91cf\u6070\u597d\u662f\u5bf9\u8c61<\/span><span style=\"color:null\">&#xff0c;\u5bf9\u8c61\u521d\u59cb\u5316\u9700\u8981\u901a\u8fc7\u6784\u9020\u6765\u521b\u5efa&#xff0c;\u6240\u4ee5\u5148\u6267\u884c\u4e86\u4e24\u6b21\u6784\u9020\u4ee3\u7801\u5757&#xff0c;\u7136\u540e\u624d\u662f\u9759\u6001\u4ee3\u7801\u5757<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><span style=\"color:null\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u52a0\u8f7d\u5b8cB\u7c7b&#xff0c;\u7ee7\u7eed\u521b\u5efa\u5bf9\u8c61&#xff0c;\u6267\u884c\u6784\u9020\u4ee3\u7801\u5757<\/span><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"150\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730145749-688a32ed4a92d.png\" width=\"148\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\n<h2>\u516d\u3001\u603b\u7ed3\u53ca\u6613\u8e29\u5751\u7684\u70b9<\/h2>\n<h3>1\u3001\u6784\u9020\u65b9\u6cd5\u4e2d\u4fee\u6539\u9759\u6001\u53d8\u91cf<\/h3>\n<p>\/\/ \u4e0d\u63a8\u8350\u7684\u505a\u6cd5<br \/>\nclass Example {<br \/>\n    static int count &#061; 0;<\/p>\n<p>    public Example() {<br \/>\n        count &#061; 0; \/\/ \u6bcf\u6b21\u521b\u5efa\u5bf9\u8c61\u90fd\u4f1a\u91cd\u7f6e\u9759\u6001\u53d8\u91cf<br \/>\n    }<br \/>\n}<\/p>\n<h3>2\u3001\u9759\u6001\u65b9\u6cd5\u8bbf\u95ee\u975e\u9759\u6001\u6210\u5458<\/h3>\n<p>class Example {<br \/>\n    int instanceVar &#061; 10;<\/p>\n<p>    public static void staticMethod() {<br \/>\n        \/\/ \u9519\u8bef&#xff1a;\u65e0\u6cd5\u76f4\u63a5\u8bbf\u95ee\u5b9e\u4f8b\u53d8\u91cf<br \/>\n        \/\/ System.out.println(instanceVar);<br \/>\n    }<br \/>\n}<\/p>\n<h3>3\u3001\u9759\u6001\u65b9\u6cd5\u8c03\u7528\u975e\u9759\u6001\u65b9\u6cd5<\/h3>\n<p>class Example {<br \/>\n    public void instanceMethod() {<br \/>\n        System.out.println(&#034;\u5b9e\u4f8b\u65b9\u6cd5&#034;);<br \/>\n    }<\/p>\n<p>    public static void staticMethod() {<br \/>\n        \/\/ \u9519\u8bef&#xff1a;\u65e0\u6cd5\u76f4\u63a5\u8c03\u7528\u5b9e\u4f8b\u65b9\u6cd5<br \/>\n        \/\/ instanceMethod();<br \/>\n    }<br \/>\n}<\/p>\n<h3>4\u3001\u9759\u6001\u4e0a\u4e0b\u6587\u4e2d\u7684 this \u5173\u952e\u5b57<\/h3>\n<p>class Example {<br \/>\n    static int staticVar &#061; 10;<\/p>\n<p>    public static void staticMethod() {<br \/>\n        \/\/ \u9519\u8bef&#xff1a;\u9759\u6001\u65b9\u6cd5\u4e2d\u6ca1\u6709 this<br \/>\n        \/\/ this.staticVar &#061; 20;<br \/>\n    }<br \/>\n}<\/p>\n<h3>5\u3001\u521d\u59cb\u5316\u987a\u5e8f\u95ee\u9898<\/h3>\n<p>\u591a\u4e2a\u9759\u6001\u53d8\u91cf\u548c\u9759\u6001\u4ee3\u7801\u5757\u540c\u65f6\u5b58\u5728\u65f6&#xff0c;\u8c01\u5728\u540e\u6700\u540e\u7ed3\u679c\u5c31\u662f\u8c01\u7684<\/p>\n<p>public class Static {<br \/>\n    \/\/\u9759\u6001\u6210\u5458\u53d8\u91cf\u663e\u793a\u521d\u59cb\u5316<br \/>\n    private static String Library &#061; &#034;\u680b\u6881\u56fe\u4e66\u9986&#034;;<\/p>\n<p>    \/\/\u9759\u6001\u4ee3\u7801\u5757\u7ed9\u9759\u6001\u6210\u5458\u53d8\u91cf\u8d4b\u503c<br \/>\n    static{<br \/>\n        Library &#061; &#034;\u51cc\u4e91\u56fe\u4e66\u9986&#034;;<br \/>\n    }<\/p>\n<p>    static{<br \/>\n        Library1 &#061; &#034;\u51cc\u4e91\u56fe\u4e66\u9986&#034;;<br \/>\n        System.out.println(&#034;\u9759\u6001\u4ee3\u7801\u5757&#034;);<br \/>\n    }<\/p>\n<p>    public Static(){<br \/>\n        System.out.println(&#034;\u6784\u9020\u65b9\u6cd5&#034;);<br \/>\n    }<\/p>\n<p>    private static String Library1 &#061; &#034;\u680b\u6881\u56fe\u4e66\u9986&#034;;<\/p>\n<p>    public static void main(String[] args) {<br \/>\n        Static s &#061; new Static();<br \/>\n        System.out.println(Library);<br \/>\n        System.out.println(Library1);<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/\u7ed3\u679c\u4e3a&#xff1a;<br \/>\n\/\/\u9759\u6001\u4ee3\u7801\u5757<br \/>\n\/\/\u6784\u9020\u65b9\u6cd5<br \/>\n\/\/\u51cc\u4e91\u56fe\u4e66\u9986<br \/>\n\/\/\u680b\u6881\u56fe\u4e66\u9986<\/p>\n<h3>6\u3001\u5de5\u5177\u7c7b\u8bbe\u8ba1<\/h3>\n<p>\u5bf9\u4e8e\u53ea\u5305\u542b\u9759\u6001\u65b9\u6cd5\u7684\u5de5\u5177\u7c7b&#xff1a;<\/p>\n<p>\u2014\u2014\u5e94\u8be5\u58f0\u660e\u4e3a final \u7c7b\u9632\u6b62\u7ee7\u627f<\/p>\n<p>\u2014\u2014\u6784\u9020\u65b9\u6cd5\u5e94\u8bbe\u4e3a\u79c1\u6709\u9632\u6b62\u5b9e\u4f8b\u5316<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u8bf6&#xff0c;<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u8fd9\u6b21\u6ca1\u6709\u95ee\u9898\u4e86<\/span><\/p>\n<p><span style=\"color:#fe2c24\">final\u5173\u952e\u5b57\u5148\u6b20\u7740&#xff0c;\u4e0b\u6b21\u518d\u5206\u4eab~<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"150\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730145749-688a32ed765fc.png\" width=\"150\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb64\u6b21\uff0c\u70b9\u8d5e2\u6b21\uff0c\u6536\u85cf3\u6b21\u3002\u6458\u8981\uff1a\u672c\u6587\u6df1\u5165\u8bb2\u89e3\u4e86Java\u4e2dstatic\u5173\u952e\u5b57\u7684\u7528\u6cd5\u4e0e\u7279\u6027\u3002static\u7528\u4e8e\u4fee\u9970\u6210\u5458\u53d8\u91cf\u3001\u65b9\u6cd5\u548c\u4ee3\u7801\u5757\uff0c\u4f7f\u5176\u6210\u4e3a\u7c7b\u7ea7\u522b\u7684\u5171\u4eab\u8d44\u6e90\u3002\u9759\u6001\u6210\u5458\u53d8\u91cf\u5b58\u50a8\u5728\u65b9\u6cd5\u533a\uff0c\u88ab\u6240\u6709\u5b9e\u4f8b\u5171\u4eab\uff1b\u9759\u6001\u65b9\u6cd5\u53ea\u80fd\u8bbf\u95ee\u9759\u6001\u6210\u5458\uff0c\u4e0d\u80fd\u4f7f\u7528this\u548csuper\u3002\u6587\u7ae0\u5bf9\u6bd4\u4e86\u9759\u6001\u4e0e\u975e\u9759\u6001\u6210\u5458\u7684\u533a\u522b\uff0c\u5305\u62ec\u5b58\u50a8\u4f4d\u7f6e\u3001\u751f\u547d\u5468\u671f\u3001\u8c03\u7528\u65b9\u5f0f\u7b49\uff0c\u5e76\u5206\u6790\u4e86\u9759\u6001\u4ee3\u7801\u5757\u3001\u6784\u9020\u4ee3\u7801\u5757\u7684\u6267\u884c\u987a\u5e8f\u3002\u6b64\u5916\uff0c\u8fd8\u4ecb\u7ecd\u4e86\u5355\u4f8b\u6a21\u5f0f\u7684\u5b9e\u73b0\u3001\u5de5\u5177\u7c7b\u8bbe\u8ba1\u539f\u5219\uff0c\u4ee5\u53castatic\u5728\u7ee7\u627f\u4e2d\u7684\u7279\u70b9\uff0c\u6700\u540e\u603b\u7ed3\u4e86\u4f7f\u7528static\u65f6\u5e38\u89c1\u7684\u6613\u9519\u70b9\u3002<\/p>\n","protected":false},"author":2,"featured_media":50326,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,4904,123,190,124],"topic":[],"class_list":{"0":"post-50337","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","6":"hentry","7":"category-server","8":"tag-java","10":"tag-123","11":"tag-190","12":"tag-124"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5927\u5b66\u751f\u5165\u95e8\uff1astatic\u53ca\u5176\u6613\u8e29\u5751\u7684\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\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.wsisp.com\/helps\/50337.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5927\u5b66\u751f\u5165\u95e8\uff1astatic\u53ca\u5176\u6613\u8e29\u5751\u7684\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb64\u6b21\uff0c\u70b9\u8d5e2\u6b21\uff0c\u6536\u85cf3\u6b21\u3002\u6458\u8981\uff1a\u672c\u6587\u6df1\u5165\u8bb2\u89e3\u4e86Java\u4e2dstatic\u5173\u952e\u5b57\u7684\u7528\u6cd5\u4e0e\u7279\u6027\u3002static\u7528\u4e8e\u4fee\u9970\u6210\u5458\u53d8\u91cf\u3001\u65b9\u6cd5\u548c\u4ee3\u7801\u5757\uff0c\u4f7f\u5176\u6210\u4e3a\u7c7b\u7ea7\u522b\u7684\u5171\u4eab\u8d44\u6e90\u3002\u9759\u6001\u6210\u5458\u53d8\u91cf\u5b58\u50a8\u5728\u65b9\u6cd5\u533a\uff0c\u88ab\u6240\u6709\u5b9e\u4f8b\u5171\u4eab\uff1b\u9759\u6001\u65b9\u6cd5\u53ea\u80fd\u8bbf\u95ee\u9759\u6001\u6210\u5458\uff0c\u4e0d\u80fd\u4f7f\u7528this\u548csuper\u3002\u6587\u7ae0\u5bf9\u6bd4\u4e86\u9759\u6001\u4e0e\u975e\u9759\u6001\u6210\u5458\u7684\u533a\u522b\uff0c\u5305\u62ec\u5b58\u50a8\u4f4d\u7f6e\u3001\u751f\u547d\u5468\u671f\u3001\u8c03\u7528\u65b9\u5f0f\u7b49\uff0c\u5e76\u5206\u6790\u4e86\u9759\u6001\u4ee3\u7801\u5757\u3001\u6784\u9020\u4ee3\u7801\u5757\u7684\u6267\u884c\u987a\u5e8f\u3002\u6b64\u5916\uff0c\u8fd8\u4ecb\u7ecd\u4e86\u5355\u4f8b\u6a21\u5f0f\u7684\u5b9e\u73b0\u3001\u5de5\u5177\u7c7b\u8bbe\u8ba1\u539f\u5219\uff0c\u4ee5\u53castatic\u5728\u7ee7\u627f\u4e2d\u7684\u7279\u70b9\uff0c\u6700\u540e\u603b\u7ed3\u4e86\u4f7f\u7528static\u65f6\u5e38\u89c1\u7684\u6613\u9519\u70b9\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/50337.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-30T14:57:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730145746-688a32ea13517.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/50337.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/50337.html\",\"name\":\"\u5927\u5b66\u751f\u5165\u95e8\uff1astatic\u53ca\u5176\u6613\u8e29\u5751\u7684\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-07-30T14:57:50+00:00\",\"dateModified\":\"2025-07-30T14:57:50+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/50337.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/50337.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/50337.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5927\u5b66\u751f\u5165\u95e8\uff1astatic\u53ca\u5176\u6613\u8e29\u5751\u7684\u70b9\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u5927\u5b66\u751f\u5165\u95e8\uff1astatic\u53ca\u5176\u6613\u8e29\u5751\u7684\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","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.wsisp.com\/helps\/50337.html","og_locale":"zh_CN","og_type":"article","og_title":"\u5927\u5b66\u751f\u5165\u95e8\uff1astatic\u53ca\u5176\u6613\u8e29\u5751\u7684\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb64\u6b21\uff0c\u70b9\u8d5e2\u6b21\uff0c\u6536\u85cf3\u6b21\u3002\u6458\u8981\uff1a\u672c\u6587\u6df1\u5165\u8bb2\u89e3\u4e86Java\u4e2dstatic\u5173\u952e\u5b57\u7684\u7528\u6cd5\u4e0e\u7279\u6027\u3002static\u7528\u4e8e\u4fee\u9970\u6210\u5458\u53d8\u91cf\u3001\u65b9\u6cd5\u548c\u4ee3\u7801\u5757\uff0c\u4f7f\u5176\u6210\u4e3a\u7c7b\u7ea7\u522b\u7684\u5171\u4eab\u8d44\u6e90\u3002\u9759\u6001\u6210\u5458\u53d8\u91cf\u5b58\u50a8\u5728\u65b9\u6cd5\u533a\uff0c\u88ab\u6240\u6709\u5b9e\u4f8b\u5171\u4eab\uff1b\u9759\u6001\u65b9\u6cd5\u53ea\u80fd\u8bbf\u95ee\u9759\u6001\u6210\u5458\uff0c\u4e0d\u80fd\u4f7f\u7528this\u548csuper\u3002\u6587\u7ae0\u5bf9\u6bd4\u4e86\u9759\u6001\u4e0e\u975e\u9759\u6001\u6210\u5458\u7684\u533a\u522b\uff0c\u5305\u62ec\u5b58\u50a8\u4f4d\u7f6e\u3001\u751f\u547d\u5468\u671f\u3001\u8c03\u7528\u65b9\u5f0f\u7b49\uff0c\u5e76\u5206\u6790\u4e86\u9759\u6001\u4ee3\u7801\u5757\u3001\u6784\u9020\u4ee3\u7801\u5757\u7684\u6267\u884c\u987a\u5e8f\u3002\u6b64\u5916\uff0c\u8fd8\u4ecb\u7ecd\u4e86\u5355\u4f8b\u6a21\u5f0f\u7684\u5b9e\u73b0\u3001\u5de5\u5177\u7c7b\u8bbe\u8ba1\u539f\u5219\uff0c\u4ee5\u53castatic\u5728\u7ee7\u627f\u4e2d\u7684\u7279\u70b9\uff0c\u6700\u540e\u603b\u7ed3\u4e86\u4f7f\u7528static\u65f6\u5e38\u89c1\u7684\u6613\u9519\u70b9\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/50337.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-07-30T14:57:50+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730145746-688a32ea13517.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/50337.html","url":"https:\/\/www.wsisp.com\/helps\/50337.html","name":"\u5927\u5b66\u751f\u5165\u95e8\uff1astatic\u53ca\u5176\u6613\u8e29\u5751\u7684\u70b9 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-07-30T14:57:50+00:00","dateModified":"2025-07-30T14:57:50+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/50337.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/50337.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/50337.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u5927\u5b66\u751f\u5165\u95e8\uff1astatic\u53ca\u5176\u6613\u8e29\u5751\u7684\u70b9"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/50337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=50337"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/50337\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/50326"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=50337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=50337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=50337"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=50337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}