{"id":626,"date":"2023-12-23T18:01:01","date_gmt":"2023-12-23T10:01:01","guid":{"rendered":""},"modified":"2023-12-23T18:01:01","modified_gmt":"2023-12-23T10:01:01","slug":"java\u4e2d\u91cd\u8f7d\u548c\u91cd\u5199\u7684\u533a\u522b","status":"publish","type":"post","link":"https:\/\/mushiming.com\/626.html","title":{"rendered":"java\u4e2d\u91cd\u8f7d\u548c\u91cd\u5199\u7684\u533a\u522b"},"content":{"rendered":"
\u91cd\u8f7d\u6307\u5728\u4e00\u4e2a\u7c7b\u4e2d\uff0c\u5177\u6709\u591a\u4e2a\u76f8\u540c\u540d\u79f0\u7684\u65b9\u6cd5<\/strong>\uff0c\u4ed6\u4eec\u7684\u53c2\u6570\u5217\u8868\u5374\u4e0d\u76f8\u540c<\/strong><\/p>\n \uff08\u53c2\u6570\u7c7b\u578b\u4e0d\u540c\u3001\u53c2\u6570\u4e2a\u6570\u4e0d\u540c\u751a\u81f3\u662f\u53c2\u6570\u987a\u5e8f\u4e0d\u540c<\/strong>\uff09<\/p>\n \u91cd\u8f7d\u5bf9\u8fd4\u56de\u7c7b\u578b\u6ca1\u6709\u8981\u6c42\uff0c\u53ef\u4ee5\u76f8\u540c\u4e5f\u53ef\u4ee5\u4e0d\u540c\uff0c\u4f46\u662f\u4e0d\u80fd\u8fd4\u56de\u7c7b\u578b\u6765\u5224\u65ad\u4ed6\u4eec\u662f\u5426\u662f\u91cd\u8f7d\u3002<\/p>\n \u4f8b\u5982<\/p>\n \u603b\u7ed3\uff1a<\/p>\n 1.\u91cd\u8f7d\u662f\u4e00\u4e2a\u7c7b\u4e2d\u591a\u6001\u6027\u7684\u4e00\u79cd\u8868\u73b0<\/strong><\/p>\n 2.\u91cd\u8f7d\u662f\u5728\u4e00\u4e2a\u7c7b\u4e2d\uff0c\u5177\u6709\u76f8\u540c\u540d\u79f0\u4e0d\u540c\u53c2\u6570\u5217\u8868\u7684\u65b9\u6cd5<\/strong><\/p>\n 3.\u91cd\u8f7d\u4e0d\u80fd\u6839\u636e\u8fd4\u56de\u7c7b\u578b\u7684\u76f8\u540c\u6216\u8005\u4e0d\u540c\u6765\u533a\u5206\u91cd\u8f7d\u51fd\u6570\u3002<\/strong><\/p>\n<\/p>\n 1.\u91cd\u5199\u662f\u6307\u5728\u4e0d\u540c\u7c7b\u4e2d\uff0c\u5c06\u7236\u7c7b\u7684\u65b9\u6cd5\u5728\u5b50\u7c7b\u4e2d\u91cd\u65b0\u5199\u4e00\u904d<\/strong>\uff0c\u5b50\u7c7b\u7ee7\u627f\u4e86\u7236\u7c7b\u539f\u6709\u7684\u65b9\u6cd5\uff0c\u4f46\u6709\u65f6\u53c8\u4e0d\u60f3\u7ee7\u627f\u7236\u7c7b\u539f\u6709\u4e00\u6a21\u4e00\u6837\u7684\u65b9\u6cd5\uff0c\u6240\u4ee5\u5c31\u5728\u8fd4\u56de\u7c7b\u578b\uff0c\u65b9\u6cd5\u540d\uff0c\u53c2\u6570\u5217\u8868\u76f8\u540c<\/strong>\u7684\u60c5\u51b5\u4e0b\uff0c\u5bf9\u65b9\u6cd5\u4f53\u8fdb\u884c\u4fee\u6539\u8fdb\u884c\u91cd\u5199\uff0c\u8fd9\u5c31\u662f\u91cd\u5199\u3002\u4f46\u6ce8\u610f\u7684\u662f \u5b50\u7c7b\u7684\u8bbf\u95ee\u4fee\u9970\u7b26\u4e0d\u80fd\u6bd4\u7236\u7c7b\u7684\u66f4\u4e25\u683c<\/strong>\uff08\u610f\u601d\u5c31\u662f\u7236\u7c7b\u7684\u8bbf\u95ee\u4fee\u9970\u7b26\u8981\u66f4\u52a0 \u4e25\u8c28\uff0c\u6743\u9650\u66f4\u5c11\uff0c\u7236\u4eb2\u4e25\u683c<\/strong>\uff09<\/p>\n \u4f8b\u5982<\/p>\n \u8fd4\u56de\u7ed3\u679c\u662f<\/p>\n <\/p>\n \u91cd\u5199\u7684\u603b\u7ed3\uff1a<\/strong><\/p>\n 1. \u53d1\u751f\u5728\u7236\u7c7b\u548c\u5b50\u7c7b\u5173\u7cfb\u4e4b\u95f4<\/strong><\/p>\n 2. \u4ed6\u4eec\u7684\u8fd4\u56de\u7c7b\u578b\uff0c\u65b9\u6cd5\u540d\uff0c\u5217\u8868\u53c2\u6570\u76f8\u540c \u65b9\u6cd5\u4f53\u4e0d\u540c\u3002<\/strong><\/p>\n 3.\u5b50\u7c7b\u4e0d\u80fd\u6bd4\u7236\u7c7b\u66f4\u4e25\u683c \uff0c\uff08\u7236\u4eb2\u6bd4\u513f\u5b50\u4e25\u683c\uff09\u3002<\/strong><\/p>\n 4\u91cd\u5199\u65b9\u6cd5\u4e00\u5b9a\u4e0d\u80fd\u629b\u51fa\u65b0\u7684\u68c0\u67e5\u5f02\u5e38\u6216\u8005\u6bd4\u88ab\u91cd\u5199\u65b9\u6cd5\u7533\u660e\u66f4\u52a0\u5bbd\u6cdb\u7684\u68c0\u67e5\u578b\u5f02\u5e38<\/strong><\/p>\n<\/p>\n <\/p>\n private \u6700\u4e25\u683c\u3002<\/p>\n private : \u5728\u540c\u4e00\u7c7b\u5185\u53ef\u89c1\u3002\u4f7f\u7528\u5bf9\u8c61\uff1a\u53d8\u91cf\u3001\u65b9\u6cd5\u3002<\/strong> \u6ce8\u610f\uff1a\u4e0d\u80fd\u4fee\u9970\u7c7b\uff08\u5916\u90e8\u7c7b\uff09<\/strong> \u603b\u7ed3\u91cd\u8f7d\u548c\u91cd\u5199\u7684\u533a\u522b\uff1a<\/strong><\/p>\n \u7b54\uff1a\u65b9\u6cd5\u7684\u91cd\u8f7d\u548c\u91cd\u5199\u90fd\u662f\u5b9e\u73b0\u591a\u6001\u7684\u65b9\u5f0f \uff0c\u533a\u522b\u5728\u4e8e\u91cd\u8f7d\u5b9e\u73b0\u7684\u662f\u7f16\u8bd1\u65f6\u7684\u591a\u6001\u6027\uff0c\u91cd\u5199\u5b9e\u73b0\u7684\u8fd0\u884c\u65f6\u7684\u591a\u6001\u6027\u3002<\/strong><\/p>\n \u91cd\u8f7d\u662f\u5728\u53d1\u751f\u5728\u540c\u4e00\u4e2a\u7c7b\u4e2d\uff0c\u4ed6\u4eec\u6709\u76f8\u540c\u7684\u65b9\u6cd5\u540d \uff0c\u4f46\u6709\u4e0d\u540c\u7684\u53c2\u6570\u5217\u8868\uff0c\u91cd\u8f7d\u5bf9\u8fd4\u56de\u7c7b\u578b\u6ca1\u6709\u7279\u522b\u8981\u6c42\uff0c\u4e0d\u80fd\u6839\u636e\u8fd4\u56de\u7c7b\u578b\u6765\u8fdb\u884c\u533a\u5206 \u3002<\/strong><\/p>\n \u800c\u91cd\u5199\u53d1\u751f\u5728\u4e0d\u540c\u7c7b\u4e2d\uff0c\u53d1\u751f\u5728\u5b50\u7c7b\u548c\u7236\u7c7b\u4e4b\u95f4\u7684\uff0c\u91cd\u5199\u8981\u6c42\u5b50\u7c7b\u4e0e\u7236\u7c7b\u7684\u88ab\u91cd\u5199\u65b9\u6cd5\u5177\u6709\u76f8\u540c\u7684\u8fd4\u56de\u7c7b\u578b\uff0c\u540d\u79f0\u548c\u53c2\u6570\u5217\u8868\u3002 \u4f46\u4ed6\u4eec\u7684\u65b9\u6cd5\u4f53\u8981\u4e0d\u540c\u3002 \u540c\u65f6\uff0c\u7236\u7c7b\u76f8\u8f83\u4e8e\u5b50\u7c7b\uff0c\u4ed6\u7684\u8bbf\u95ee\u4fee\u9970\u7b26\u4f1a\u66f4\u52a0\u4e25\u683c\uff0c\u5373\u8bbf\u95ee\u8303\u56f4\u66f4\u5c0f\u3002\u6bd4\u7236\u7c7b\u88ab\u91cd\u5199\u65b9\u6cd5\u66f4\u597d\u8bbf\u95ee\uff0c\u4e0d\u80fd\u6bd4\u7236\u7c7b\u88ab\u91cd\u5199\u65b9\u6cd5\u58f0\u660e\u66f4\u591a\u7684\u5f02\u5e38\uff08\u91cc\u6c0f\u4ee3\u6362\u539f\u5219\uff09 \u3002<\/strong><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"java\u4e2d\u91cd\u8f7d\u548c\u91cd\u5199\u7684\u533a\u522b1.\u91cd\u8f7d\u91cd\u8f7d\u6307\u5728\u4e00\u4e2a\u7c7b\u4e2d\uff0c\u5177\u6709\u591a\u4e2a\u76f8\u540c\u540d\u79f0\u7684\u7c7b\uff0c\u4ed6\u4eec\u7684\u53c2\u6570\u5217\u8868\u5374\u4e0d\u76f8\u540c\uff08\u53c2\u6570\u7c7b\u578b\u4e0d\u540c\u3001\u53c2\u6570\u4e2a\u6570\u4e0d...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/626"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=626"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/626\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=626"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=626"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=626"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}package HelloWorld;\n\npublic class Zuoye {\n\tpublic static void main(String[] args) {\n\t\tZuoye z = new Zuoye();\n\t\tz.fangfa1();\n\t\tz.fangfa1(\"\u5f20\u65ed\");\n\t}\n\t\n\tpublic void fangfa1() {\n\t\tSystem.out.println(\"\u65b9\u6cd51\");\n\t}\n\tpublic void fangfa1(String name) {\n\t\tSystem.out.println(\"\u4e5f\u662f\u65b9\u6cd51\uff0c\u4e0d\u8fc7\u6709\u53c2\u6570\"+ name);\n\t}\n}<\/code><\/pre>\n
2.\u91cd\u5199<\/h1>\n
package HelloWorld;\n\npublic class Father {\n public static void main(String[] args) {\n \t Son s = new Son();\n \t s.fangfa();\n\t}\n\tpublic void fangfa() {\n\t\tSystem.out.println(\"\u6211\u662f\u7238\u7238\u7684\u65b9\u6cd5\");\n\t}\n}\nclass Son extends Father {\n\tpublic void fangfa() {\n\t\tSystem.out.println(\"\u6211\u662f\u513f\u5b50\u7684\u65b9\u6cd5\");\n\t}\n}\n<\/code><\/pre>\n
default (\u5373\u7f3a\u7701\uff0c\u4ec0\u4e48\u4e5f\u4e0d\u5199\uff0c\u4e0d\u4f7f\u7528\u4efb\u4f55\u5173\u952e\u5b57\uff09: \u5728\u540c\u4e00\u5305\u5185\u53ef\u89c1\uff0c\u4e0d\u4f7f\u7528\u4efb\u4f55\u4fee\u9970\u7b26\u3002\u4f7f\u7528\u5bf9\u8c61\uff1a\u7c7b\u3001\u63a5\u53e3\u3001\u53d8\u91cf\u3001\u65b9\u6cd5<\/strong>\u3002
protected : \u5bf9\u540c\u4e00\u5305\u5185\u7684\u7c7b\u548c\u6240\u6709\u5b50\u7c7b\u53ef\u89c1\u3002\u4f7f\u7528\u5bf9\u8c61\uff1a\u53d8\u91cf\u3001\u65b9\u6cd5\u3002<\/strong> \u6ce8\u610f\uff1a\u4e0d\u80fd\u4fee\u9970\u7c7b\uff08\u5916\u90e8\u7c7b\uff09<\/strong>\u3002
public : \u5bf9\u6240\u6709\u7c7b\u53ef\u89c1\u3002\u4f7f\u7528\u5bf9\u8c61\uff1a\u7c7b\u3001\u63a5\u53e3\u3001\u53d8\u91cf\u3001\u65b9\u6cd5<\/strong><\/p>\n<\/p>\n\n