{"id":45429,"date":"2023-04-07T01:38:41","date_gmt":"2023-04-06T17:38:41","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=45429"},"modified":"2023-04-07T01:38:41","modified_gmt":"2023-04-06T17:38:41","slug":"java-subclass-superclass","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/java-subclass-superclass.html","title":{"rendered":"Java\u4e2d\u5b50\u7c7b\u91cd\u5199\u7236\u7c7b\u65b9\u6cd5\u7684\u601d\u60f3\u672c\u8d28\uff01"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nJava\u8bed\u8a00\u4e2d\uff0c\u5728\u5b50\u7c7b\u4e2d\u5b9a\u4e49\u4e0e\u7236\u7c7b\u540c\u8fd4\u540c\u540d\u540c\u53c2\u7684\u65b9\u6cd5\u5c06\u4f1a\u51fa\u73b0\u201c\u91cd\u5199(\u8986\u5199)\u201d\uff0c\u5b50\u7c7b\u5c06\u5c4f\u853d\u7236\u7c7b\u7684\u76f8\u540c\u65b9\u6cd5\uff0c\u8c03\u7528\u5b50\u7c7b\u7684\u65b9\u6cd5\u5c06\u4e0d\u4f1a\u8c03\u7528\u5230\u7236\u7c7b\u7684\u8be5\u65b9\u6cd5\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u8bb8\u591a\u521d\u5b66\u8005\u4e5f\u8bb8\u4f1a\u88ab\u201c\u8986\u5199\u201d\u4e00\u8bcd\u8ff7\u60d1\uff0c\u4ee5\u4e3a\u8986\u76d6\u6389\u4e86\u7236\u7c7b\u7684\u65b9\u6cd5\uff0c\u5176\u5b9e\u8fd9\u4e24\u79cd\u65b9\u6cd5\u662f\u540c\u65f6\u72ec\u7acb\u5b58\u5728\u7684\uff0c\u53ea\u662f\u5b50\u7236\u7c7b\u8c03\u7528\u8be5\u65b9\u6cd5\u7684\u5165\u53e3\u4e0d\u4e00\u6837\uff0c\u5f7c\u6b64\u4e92\u4e0d\u5e72\u6270\u3002<\/p>\n

\/*\r\n\u9700\u6c42\uff1a\u8bbe\u8ba1\u4e00\u4e2a\u7b80\u5355\u7684java\u7a0b\u5e8f\uff0c\u8bc1\u660e\u5b50\u7c7b\u91cd\u5199\u7236\u7c7b\u65b9\u6cd5\u7684\u8fc7\u7a0b\r\n\u601d\u8def\uff1a 1\u3001\u521b\u5efa\u7236\u7c7b\u5bf9\u8c61\uff0c\u901a\u8fc7\u7236\u7c7b\u5bf9\u8c61\u8c03\u7528\u8be5\u65b9\u6cd5\r\n2\u3001\u521b\u5efa\u5b50\u7c7b\u5bf9\u8c61\uff0c\u901a\u8fc7\u7236\u7c7b\u5bf9\u8c61\u8c03\u7528\u8be5\u65b9\u6cd5\r\n3\u3001\u901a\u8fc7\u5b50\u7c7b\u5bf9\u8c61\u8c03\u7528\u8be5\u65b9\u6cd5\r\n*\/\r\nclass RerridingTest\r\n{\r\npublic static void main(String[] args)\r\n{\r\nFather f = new Father();\r\nf.show();\r\nChild c = new Child();\r\nf.show();\/\/\u521b\u5efa\u5b50\u7c7b\u5bf9\u8c61\u5e76\u6ca1\u6709\u201c\u8986\u76d6\u201d\u6389\u7236\u7c7b\u81ea\u5df1\u7684show()\u65b9\u6cd5\r\nc.show();\/\/\u5b50\u7c7b\u8c03\u7528\u540c\u540d\u65b9\u6cd5\u65f6\u76f4\u63a5\u8bbf\u95ee\u81ea\u5df1\u5b9a\u4e49\u7684\u65b9\u6cd5\uff0c\u5e76\u6ca1\u6709\u8bbf\u95ee\u7236\u7c7b\u7684\u65b9\u6cd5\r\n}\r\n}\r\n\r\nclass Father\r\n{\r\nvoid show(){\r\nSystem.out.println(\"father show run.\");\r\n}\r\n}\r\n\r\nclass Child extends Father\r\n{\r\nvoid show(){\r\nSystem.out.println(\"child show run.\");\r\n}\r\n}\r\n\r\n\/*\r\n\u603b\u7ed3\uff1a\u91cd\u5199\u8fc7\u7a0b\u662f\r\n\u521b\u5efa\u5b50\u7c7b\u5bf9\u8c61\u65f6\uff0c\u56e0\u4e3a\u5b50\u7c7b\u4e2d\u5df2\u6709\u5b9a\u4e49\u8be5\u65b9\u6cd5\uff0c\u6545\u4e0d\u4ece\u7236\u7c7b\u7ee7\u627f\u8be5\u65b9\u6cd5\uff1b\r\n\u8c03\u7528\u65b9\u6cd5\u65f6\uff0c\u5224\u65ad\u8c03\u7528\u5bf9\u8c61\u5728\u5185\u5b58\u4e2d\u662f\u4f55\u79cd\u7c7b\u578b\uff0c\u7136\u540e\u5230\u76f8\u5e94\u7c7b\u578b\u7684\u65b9\u6cd5\u533a\u4e2d\u5bfb\u627e\u8be5\u65b9\u6cd5\r\n*\/<\/pre>\n

\u7ed3\u679c\uff1a<\/p>\n

\"\u56fe\u7247\u63cf\u8ff0\"<\/p>\n

\u603b\u7ed3\uff1a<\/strong><\/div>\n

\u91cd\u5199\u8fc7\u7a0b\u662f\u521b\u5efa\u5b50\u7c7b\u5bf9\u8c61\u65f6\uff0c\u56e0\u4e3a\u5b50\u7c7b\u4e2d\u5df2\u6709\u5b9a\u4e49\u8be5\u65b9\u6cd5\uff0c\u6545\u4e0d\u4ece\u7236\u7c7b\u7ee7\u627f\u8be5\u65b9\u6cd5\uff1b\u8c03\u7528\u65b9\u6cd5\u65f6\uff0c\u5224\u65ad\u8c03\u7528\u5bf9\u8c61\u5728\u5185\u5b58\u4e2d\u662f\u4f55\u79cd\u7c7b\u578b\uff0c\u7136\u540e\u5230\u76f8\u5e94\u7c7b\u578b\u7684\u65b9\u6cd5\u533a\u4e2d\u5bfb\u627e\u8be5\u65b9\u6cd5\u3002<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/geek.csdn.net\/news\/detail\/131740<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttp:\/\/lrxjmw.cn\/java-subclass-superclass.html<\/a>\u7f16\u8f91\uff1a\u9ad8\u519b\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb Java\u8bed\u8a00\u4e2d\uff0c\u5728\u5b50\u7c7b\u4e2d\u5b9a\u4e49\u4e0e\u7236\u7c7b\u540c\u8fd4\u540c\u540d\u540c\u53c2\u7684\u65b9\u6cd5\u5c06\u4f1a\u51fa\u73b0\u201c\u91cd\u5199(\u8986\u5199)\u201d\uff0c\u5b50\u7c7b\u5c06\u5c4f\u853d\u7236\u7c7b\u7684\u76f8\u540c\u65b9\u6cd5\uff0c […]<\/p>\n","protected":false},"author":63,"featured_media":45446,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-45429","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/45429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=45429"}],"version-history":[{"count":6,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/45429\/revisions"}],"predecessor-version":[{"id":269242,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/45429\/revisions\/269242"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/45446"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=45429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=45429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=45429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}