{"id":203154,"date":"2025-05-22T13:05:30","date_gmt":"2025-05-22T05:05:30","guid":{"rendered":"https:\/\/server.hk\/cnblog\/203154\/"},"modified":"2025-05-22T13:05:30","modified_gmt":"2025-05-22T05:05:30","slug":"%e6%8e%a5%e5%8f%a3%e5%92%8c%e6%89%a9%e5%b1%95%e4%b8%ad%e7%9a%84%e5%8f%98%e9%87%8f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/203154\/","title":{"rendered":"\u63a5\u53e3\u548c\u6269\u5c55\u4e2d\u7684\u53d8\u91cf"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u63a5\u53e3\u548c\u6269\u5c55\u4e2d\u7684\u53d8\u91cf<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span>    <\/p>\n<p>\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5206\u4eab\u300a\u63a5\u53e3\u548c\u6269\u5c55\u4e2d\u7684\u53d8\u91cf\u300b\uff0c\u8986\u76d6\u4e86\u6587\u7ae0\u7684\u5e38\u89c1\u57fa\u7840\u77e5\u8bc6\uff0c\u5176\u5b9e\u4e00\u4e2a\u8bed\u8a00\u7684\u5168\u90e8\u77e5\u8bc6\u70b9\u4e00\u7bc7\u6587\u7ae0\u662f\u4e0d\u53ef\u80fd\u8bf4\u5b8c\u7684\uff0c\u4f46\u5e0c\u671b\u901a\u8fc7\u8fd9\u4e9b\u95ee\u9898\uff0c\u8ba9\u8bfb\u8005\u5bf9\u81ea\u5df1\u7684\u638c\u63e1\u7a0b\u5ea6\u6709\u4e00\u5b9a\u7684\u8ba4\u8bc6(B \u6570)\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u66f4\u597d\u7684\u638c\u63e1\u5b83\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241030\/17302714536721d8dd77463.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u9690\u5f0f\u53d8\u91cf\u58f0\u660e\uff1a<\/strong><\/p>\n<ul>\n<li>\u63a5\u53e3\u4e2d\u58f0\u660e\u7684\u53d8\u91cf\u81ea\u52a8\u662f\u516c\u5171\u7684\u3001\u9759\u6001\u7684\u548c\u6700\u7ec8\u7684\u3002<\/li>\n<li>\u5bf9\u4e8e\u5728\u5927\u578b\u7a0b\u5e8f\u4e2d\u521b\u5efa\u5171\u4eab\u5e38\u91cf\u5f88\u6709\u7528\u3002<\/li>\n<\/ul>\n<p>\u4ee3\u7801\u793a\u4f8b\uff1a<\/p>\n<pre>\n\n\/\/ interface que cont\u00e9m constantes\ninterface iconst {\n    int min = 0;\n    int max = 10;\n    string errormsg = \"boundary error\";\n}\n\nclass iconstd implements iconst {\n    public static void main(string[] args) {\n        int nums[] = new int[max];\n        for (int i = min; i &lt; 11; i++) {\n            if (i &gt;= max)\n                system.out.println(errormsg);\n            else {\n                nums[i] = i;\n                system.out.print(nums[i] + \" \");\n            }\n        }\n    }\n}\n\n\n\n<\/pre>\n<p>\u6ce8\u610f\uff1a\u867d\u7136\u5bf9\u4e8e\u5e38\u91cf\u5f88\u6709\u7528\uff0c\u4f46\u8fd9\u79cd\u6280\u672f\u53ef\u80fd\u5b58\u5728\u4e89\u8bae\u3002<\/p>\n<p><strong>\u63a5\u53e3\u53ef\u6269\u5c55<\/strong><\/p>\n<p><strong>\u63a5\u53e3\u7ee7\u627f\uff1a<\/strong><\/p>\n<ul>\n<li>\u63a5\u53e3\u53ef\u4ee5\u901a\u8fc7extends\u5173\u952e\u5b57\u7ee7\u627f\u5176\u4ed6\u63a5\u53e3\u3002<\/li>\n<li>\u5b9e\u73b0\u6d3e\u751f\u63a5\u53e3\u7684\u7c7b\u5fc5\u987b\u5b9e\u73b0\u6574\u4e2a\u63a5\u53e3\u94fe\u7684\u6240\u6709\u65b9\u6cd5\u3002<\/li>\n<\/ul>\n<p>\u4ee3\u7801\u793a\u4f8b\uff1a<\/p>\n<pre>\n\n\/\/ Interface A\ninterface A {\n    void meth1();\n    void meth2();\n}\n\n\/\/ Interface B estende A\ninterface B extends A {\n    void meth3();\n}\n\n\/\/ Classe que implementa A e B\nclass MyClass implements B {\n    public void meth1() {\n        System.out.println(\"Implement meth1().\");\n    }\n\n    public void meth2() {\n        System.out.println(\"Implement meth2().\");\n    }\n\n    public void meth3() {\n        System.out.println(\"Implement meth3().\");\n    }\n}\n\nclass IFExtend {\n    public static void main(String[] args) {\n        MyClass ob = new MyClass();\n        ob.meth1();\n        ob.meth2();\n        ob.meth3();\n    }\n}\n\n\n\n<\/pre>\n<p>\u91cd\u8981\u63d0\u793a\uff1a\u5982\u679c\u5220\u9664 meth1() \u7684\u5b9e\u73b0\uff0c\u5c06\u4f1a\u51fa\u73b0\u7f16\u8bd1\u9519\u8bef\uff0c\u56e0\u4e3a\u6240\u6709\u63a5\u53e3\u65b9\u6cd5\u90fd\u5fc5\u987b\u5b9e\u73b0\u3002<\/p>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300a\u63a5\u53e3\u548c\u6269\u5c55\u4e2d\u7684\u53d8\u91cf\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n<p>      \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1adev.to \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb\u5220\u9664<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a5\u53e3\u548c\u6269\u5c55\u4e2d\u7684\u53d8\u91cf \u6536\u85cf \u672c\u7bc7\u6587&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-203154","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=203154"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203154\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=203154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=203154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=203154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}