{"id":85,"date":"2015-03-30T11:41:37","date_gmt":"2015-03-30T03:41:37","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=85"},"modified":"2026-08-18T12:09:25","modified_gmt":"2026-08-18T04:09:25","slug":"java%e5%a4%9a%e6%80%81%e5%92%8c%e5%8a%a8%e6%80%81%e7%bb%91%e5%ae%9a","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=85","title":{"rendered":"Java\u591a\u6001"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<p style=\"margin: 1em 0px;\">\u9762\u5411\u5bf9\u8c61\u4e09\u5927\u7279\u6027\uff1a<strong style=\"color: #4870ac;\">\u5c01\u88c5<\/strong>\u3001<strong style=\"color: #4870ac;\">\u7ee7\u627f<\/strong>\u3001<strong style=\"color: #4870ac;\">\u591a\u6001<\/strong>\u3002\u5c01\u88c5\u85cf\u8d77\u5185\u90e8\u5b9e\u73b0\uff0c\u6539\u7ed3\u6784\u4e0d\u5f71\u54cd\u5916\u90e8\u7528\u6cd5\uff0c\u4e5f\u4fdd\u62a4\u6570\u636e\u2014\u2014\u5916\u754c\u53ea\u770b\u89c1\u8bbf\u95ee\u65b9\u6cd5\u3002\u7ee7\u627f\u4e3a\u4e86\u590d\u7528\u7236\u7c7b\u4ee3\u7801\uff0c\u540c\u65f6\u4e5f\u7ed9\u591a\u6001\u94fa\u8def\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u591a\u6001\u8bf4\u7684\u662f\uff1a\u540c\u4e00\u4efd\u5f15\u7528\u3001\u540c\u4e00\u6b21\u65b9\u6cd5\u8c03\u7528\uff0c\u5b9e\u9645\u8dd1\u54ea\u6bb5\u4ee3\u7801\uff0c\u53d6\u51b3\u4e8e\u5bf9\u8c61\u771f\u6b63\u7684\u7c7b\u578b\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e00\u3001\u73b0\u5b9e\u751f\u6d3b\u4e2d\u7684\u591a\u6001<\/h2>\n<p style=\"margin: 1em 0px;\">\u540c\u4e00\u4e2a F1 \u952e\uff1a\u5728\u6d4f\u89c8\u5668\u7a97\u53e3\u6253\u5f00\u65b0\u7f51\u9875\uff0c\u5728 Word \u6253\u5f00\u5e2e\u52a9\u4e2d\u5fc3\uff0c\u5728 Windows \u684c\u9762\u5f39\u51fa\u300c\u5e2e\u52a9\u548c\u652f\u6301\u300d\u3002\u6309\u952e\u884c\u4e3a\u4e00\u6837\uff0c\u8868\u73b0\u5f62\u6001\u4e0d\u540c\uff0c\u8fd9\u5c31\u662f\u751f\u6d3b\u91cc\u7684\u591a\u6001\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e8c\u3001\u8f6f\u4ef6\u4e16\u754c\u4e2d\u7684\u591a\u6001<\/h2>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">class People {\n    void say() {\n        System.out.println(\"\u5927\u5bb6\u597d\uff0c\u6211\u662f\u826f\u6c11\");\n    }\n}\nclass Teacher extends People {\n    void say() {\n        System.out.println(\"\u5927\u5bb6\u597d\uff0c\u6211\u662f\u4e00\u540d\u8001\u5e08\");\n    }\n}\npublic class Demo {\n    public static void main(String[] args) {\n        People obj = new People(); \/\/ \u5f15\u7528\u7236\u7c7b\u5b9e\u4f8b\n        obj.say();\n        obj = new Teacher(); \/\/ \u5f15\u7528\u5b50\u7c7b\u5b9e\u4f8b\n        obj.say();\n    }\n}\n\/\/ \u8fd0\u884c\u7ed3\u679c\uff1a\n\/\/ \u5927\u5bb6\u597d\uff0c\u6211\u662f\u826f\u6c11\n\/\/ \u5927\u5bb6\u597d\uff0c\u6211\u662f\u4e00\u540d\u8001\u5e08<\/code><\/pre>\n<p style=\"margin: 1em 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">obj<\/code> \u7684\u58f0\u660e\u7c7b\u578b\u662f People\uff0c\u65e2\u53ef\u4ee5\u6307\u5411 People \u5b9e\u4f8b\uff0c\u4e5f\u53ef\u4ee5\u6307\u5411 Teacher \u5b9e\u4f8b\u3002\u5b83\u6709\u65f6\u662f\u300c\u4eba\u7c7b\u300d\uff0c\u6709\u65f6\u662f\u300c\u6559\u5e08\u300d\uff0c\u5f62\u6001\u4e0d\u540c\uff0c\u5c31\u662f\u591a\u6001\u3002\u518d\u6bd4\u5982\u53bb\u5ba0\u7269\u5e97\u8bf4\u300c\u8bf7\u7ed9\u6211\u4e00\u53ea\u5ba0\u7269\u300d\uff0c\u5c0f\u732b\u3001\u5c0f\u72d7\u3001\u8725\u8734\u90fd\u7b97\u6570\u2014\u2014\u300c\u5ba0\u7269\u300d\u5177\u5907\u591a\u6001\u6027\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u53cd\u8fc7\u6765\u4e0d\u884c\uff1a\u6240\u6709\u6559\u5e08\u90fd\u662f\u4eba\uff0c\u4e0d\u662f\u6240\u6709\u4eba\u90fd\u662f\u6559\u5e08\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">public static void main(String[] args) {\n    Teacher obj = new Teacher();\n    obj.say();\n    obj = new People(); \/\/ \u7f16\u8bd1\u9519\u8bef\uff1a\u4e0d\u80fd\u628a\u7236\u7c7b\u5b9e\u4f8b\u8d4b\u7ed9\u5b50\u7c7b\u53d8\u91cf\n    obj.say();\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u7ed3\u8bba\uff1a<strong style=\"color: #4870ac;\">\u7236\u7c7b\u53d8\u91cf\u53ef\u4ee5\u5f15\u7528\u7236\u7c7b\u5b9e\u4f8b\uff0c\u4e5f\u53ef\u4ee5\u5f15\u7528\u5b50\u7c7b\u5b9e\u4f8b\uff1b\u53cd\u8fc7\u6765\u9519\u8bef\u3002<\/strong><\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e09\u3001\u591a\u6001\u7684\u4e09\u4e2a\u6761\u4ef6<\/h2>\n<table style=\"display: table; text-align: left; overflow: auto; border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; overflow-wrap: break-word; word-break: break-all;\" width=\"800\">\n<thead>\n<tr>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u6761\u4ef6<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u542b\u4e49<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u7ee7\u627f<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5fc5\u987b\u6709\u7236\u5b50\u7c7b\u5173\u7cfb<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u91cd\u5199\uff08\u8986\u76d6\uff09<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5b50\u7c7b\u91cd\u65b0\u5b9a\u4e49\u7236\u7c7b\u65b9\u6cd5\uff0c\u8c03\u7528\u65f6\u624d\u53ef\u80fd\u8d70\u5230\u5b50\u7c7b\u7248\u672c<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u7236\u7c7b\u53d8\u91cf\u5f15\u7528\u5b50\u7c7b\u5bf9\u8c61<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u7f16\u8bd1\u671f\u6309\u7236\u7c7b\u770b\u65b9\u6cd5\uff0c\u8fd0\u884c\u671f\u6309\u5b9e\u9645\u5bf9\u8c61\u7ed1\u5b9a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin: 1em 0px;\">\u7528\u591a\u6001\u65b9\u5f0f\u8c03\u7528\u65b9\u6cd5\u65f6\uff1a\u5148\u770b\u7236\u7c7b\u6709\u6ca1\u6709\u8fd9\u4e2a\u65b9\u6cd5\u2014\u2014\u6ca1\u6709\u5219\u7f16\u8bd1\u9519\u8bef\uff1b\u6709\u5219\u518d\u770b\u5b50\u7c7b\u6709\u6ca1\u6709\u8986\u76d6\u3002\u8986\u76d6\u4e86\u5c31\u8c03\u5b50\u7c7b\uff0c\u5426\u5219\u8c03\u7236\u7c7b\u3002<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u7528\u7236\u7c7b\u7c7b\u578b\u7684\u5f15\u7528\u6307\u5411\u5b50\u7c7b\u5bf9\u8c61\uff1b<\/section>\n<\/li>\n<li>\n<section>\u8be5\u5f15\u7528\u5728\u7f16\u8bd1\u671f\u53ea\u80fd\u8c03\u7528\u7236\u7c7b\u4e2d\u5b9a\u4e49\u7684\u65b9\u6cd5\u548c\u53d8\u91cf\uff1b<\/section>\n<\/li>\n<li>\n<section>\u82e5\u5b50\u7c7b\u91cd\u5199\u4e86\u7236\u7c7b\u65b9\u6cd5\uff0c\u8fd0\u884c\u65f6\u8c03\u7528\u7684\u662f\u5b50\u7c7b\u90a3\u4e00\u4efd\u3002<\/section>\n<\/li>\n<\/ul>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\">\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1a\u7236\u7c7b\u5f15\u7528\u6307\u5411\u5b50\u7c7b\u5bf9\u8c61\uff0c\u7f16\u8bd1\u770b\u7236\u7c7b\u6709\u6ca1\u6709\u65b9\u6cd5\uff0c\u8fd0\u884c\u8d70\u5b50\u7c7b\u8986\u76d6\u540e\u7684\u5b9e\u73b0\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u9762\u5411\u5bf9\u8c61\u4e09\u5927\u7279\u6027\uff1a\u5c01\u88c5\u3001\u7ee7\u627f\u3001\u591a\u6001\u3002\u5c01\u88c5\u85cf\u8d77\u5185\u90e8\u5b9e\u73b0\uff0c\u6539\u7ed3\u6784\u4e0d\u5f71\u54cd\u5916\u90e8\u7528\u6cd5\uff0c\u4e5f\u4fdd\u62a4\u6570\u636e\u2014\u2014\u5916\u754c\u53ea\u770b\u89c1\u8bbf\u95ee\u65b9\u6cd5\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[43,32],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/85"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=85"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/85\/revisions"}],"predecessor-version":[{"id":2082,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/85\/revisions\/2082"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}