{"id":629,"date":"2023-12-22T09:01:01","date_gmt":"2023-12-22T01:01:01","guid":{"rendered":""},"modified":"2023-12-22T09:01:01","modified_gmt":"2023-12-22T01:01:01","slug":"Java\u7684\u91cd\u8f7d\u548c\u91cd\u5199\u533a\u522b\uff08\u9762\u8bd5\u5e38\u89c1\uff09","status":"publish","type":"post","link":"https:\/\/mushiming.com\/629.html","title":{"rendered":"Java\u7684\u91cd\u8f7d\u548c\u91cd\u5199\u533a\u522b\uff08\u9762\u8bd5\u5e38\u89c1\uff09"},"content":{"rendered":"

    \u4eca\u5929\u5728\u770bC#\u7684\u57fa\u7840\u77e5\u8bc6\uff0c\u540c\u662f\u9762\u5411\u5bf9\u8c61\u7684\u8bed\u8a00\uff0c\u770b\u5230\u91cd\u8f7d\u548c\u91cd\u5199\uff0c\u6211\u7a81\u7136\u60f3\u4e86\u534a\u5929\uff0c\u6709\u70b9\u6a21\u7cca\u4e86\uff0c\u9a6c\u4e0a\u5ea6\u5a18\u4e00\u756a\uff0c\u56de\u60f3\u8d77\u81ea\u5df1\u5728\u5317\u4eac\u5b9e\u4e60\u7684\u9879\u76ee\uff0c\u5b9e\u9645\u4e0a\uff0c\u5f00\u53d1\u4e2d\u7ecf\u5e38\u7528\u5230\u91cd\u8f7d\u548c\u91cd\u5199\uff0c\u81ea\u5df1\u4e0d\u53bb\u603b\u7ed3\u7f62\u4e86\u3002\u4eca\u5929\u627e\u4e86\u4e00\u4efd\u6bd4\u8f83\u597d\u7684\u535a\u5ba2\uff0c\u6574\u7406\u4e0b\u6765\uff0c\u5907\u4ee5\u540e\u81ea\u5df1\u56de\u6765\u91cd\u6e29\uff0c\u8d77\u7801\u66fe\u7ecf\u6211\u601d\u8003\u8fc7\u8fd9\u6837\u7684\u95ee\u9898\u3002  
<\/span><\/p>\n

\u9996\u5148\u6211\u4eec\u6765\u8bb2\u8bb2\uff1a\u91cd\u8f7d(Overloading)<\/strong><\/span><\/span><\/p>\n

    \uff081\uff09 \u65b9\u6cd5\u91cd\u8f7d\u662f\u8ba9\u7c7b\u4ee5\u7edf\u4e00\u7684\u65b9\u5f0f\u5904\u7406\u4e0d\u540c\u7c7b\u578b\u6570\u636e\u7684\u4e00\u79cd\u624b\u6bb5\u3002\u591a\u4e2a\u540c\u540d\u51fd\u6570\u540c\u65f6\u5b58\u5728\uff0c\u5177\u6709\u4e0d\u540c\u7684\u53c2\u6570\u4e2a\u6570\/\u7c7b\u578b\u3002<\/span><\/p>\n

\u91cd\u8f7dOverloading\u662f\u4e00\u4e2a\u7c7b\u4e2d\u591a\u6001\u6027\u7684\u4e00\u79cd\u8868\u73b0\u3002<\/span><\/p>\n

    \uff082\uff09 java\u7684\u65b9\u6cd5\u91cd\u8f7d\uff0c\u5c31\u662f\u5728\u7c7b\u4e2d\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u65b9\u6cd5\uff0c\u5b83\u4eec\u5177\u6709\u76f8\u540c\u7684\u540d\u5b57\uff0c\u4f46\u5177\u6709\u4e0d\u540c\u7684\u53c2\u6570\u548c\u4e0d\u540c\u7684\u5b9a\u4e49\u3002<\/span><\/p>\n

\u8c03\u7528\u65b9\u6cd5\u65f6\u901a\u8fc7\u4f20\u9012\u7ed9\u5b83\u4eec\u7684\u4e0d\u540c\u53c2\u6570\u4e2a\u6570\u548c\u53c2\u6570\u7c7b\u578b\u6765\u51b3\u5b9a\u5177\u4f53\u4f7f\u7528\u54ea\u4e2a\u65b9\u6cd5, \u8fd9\u5c31\u662f\u591a\u6001\u6027\u3002<\/span><\/p>\n

    \uff083\uff09 \u91cd\u8f7d\u7684\u65f6\u5019\uff0c\u65b9\u6cd5\u540d\u8981\u4e00\u6837\uff0c\u4f46\u662f\u53c2\u6570\u7c7b\u578b\u548c\u4e2a\u6570\u4e0d\u4e00\u6837\uff0c\u8fd4\u56de\u503c\u7c7b\u578b\u53ef\u4ee5\u76f8\u540c\u4e5f\u53ef\u4ee5\u4e0d\u76f8\u540c\u3002\u65e0\u6cd5\u4ee5\u8fd4\u56de\u578b\u522b\u4f5c\u4e3a\u91cd\u8f7d\u51fd\u6570\u7684\u533a\u5206\u6807\u51c6\u3002<\/span><\/p>\n

    \u4e0b\u9762\u662f\u91cd\u8f7d\u7684\u4f8b\u5b50\uff1a<\/span>
    package c04.answer;\/\/\u8fd9\u662f\u5305\u540d<\/span>
    \/\/\u8fd9\u662f\u8fd9\u4e2a\u7a0b\u5e8f\u7684\u7b2c\u4e00\u79cd\u7f16\u7a0b\u65b9\u6cd5\uff0c\u5728main\u65b9\u6cd5\u4e2d\u5148\u521b\u5efa\u4e00\u4e2aDog\u7c7b\u5b9e\u4f8b\uff0c\u7136\u540e\u5728Dog\u7c7b\u7684\u6784\u9020\u65b9\u6cd5\u4e2d\u5229\u7528this\u5173\u952e\u5b57\u8c03\u7528\u4e0d\u540c\u7684bark\u65b9\u6cd5\u3002<\/span><\/p>\n

\u4e0d\u540c\u7684\u91cd\u8f7d\u65b9\u6cd5bark\u662f\u6839\u636e\u5176\u53c2\u6570\u7c7b\u578b\u7684\u4e0d\u540c\u800c\u533a\u5206\u7684\u3002<\/span><\/p>\n

    \/\/\u6ce8\u610f\uff1a\u9664\u6784\u9020\u5668\u4ee5\u5916\uff0c\u7f16\u8bd1\u5668\u7981\u6b62\u5728\u5176\u4ed6\u4efb\u4f55\u5730\u65b9\u4e2d\u8c03\u7528\u6784\u9020\u5668\u3002<\/span>
    package c04.answer;<\/span><\/p>\n

    public class Dog {
\n <\/span>
         Dog()<\/span>
         {
\n <\/span>
                this.bark();<\/span>
         }<\/span>
         void bark()\/\/bark()\u65b9\u6cd5\u662f\u91cd\u8f7d\u65b9\u6cd5<\/span>
         {
\n <\/span>
                System.out.println(\\\"no barking!\\\");<\/span>
                this.bark(\\\"female\\\", 3.4);<\/span>
         }<\/span>
         void bark(String m,double l)\/\/\u6ce8\u610f\uff1a\u91cd\u8f7d\u7684\u65b9\u6cd5\u7684\u8fd4\u56de\u503c\u90fd\u662f\u4e00\u6837\u7684\uff0c<\/span>
         {
\n <\/span>
                System.out.println(\\\"a barking dog!\\\");<\/span>
                this.bark(5, \\\"China\\\");<\/span>
         }<\/span>
         void bark(int a,String n)\/\/\u4e0d\u80fd\u4ee5\u8fd4\u56de\u503c\u533a\u5206\u91cd\u8f7d\u65b9\u6cd5\uff0c\u800c\u53ea\u80fd\u4ee5\u201c\u53c2\u6570\u7c7b\u578b\u201d\u548c\u201c\u7c7b\u540d\u201d\u6765\u533a\u5206<\/span>
         {
\n <\/span>
                System.out.println(\\\"a howling dog\\\");<\/span>
         }<\/span><\/p>\n

         public static void main(String[] args)<\/span>
         {
\n <\/span>
                Dog dog = new Dog();<\/span>
                \/\/dog.bark(); [Page]<\/span>
                \/\/dog.bark(\\\"male\\\", \\\"yellow\\\");<\/span>
                \/\/dog.bark(5, \\\"China\\\");<\/span><\/p>\n

 <\/p>\n

\u3000\u3000\u7136\u540e\u6211\u4eec\u518d\u6765\u8c08\u8c08 \u91cd\u5199\uff08Overriding\uff09<\/strong><\/span><\/span><\/p>\n

    \uff081\uff09 \u7236\u7c7b\u4e0e\u5b50\u7c7b\u4e4b\u95f4\u7684\u591a\u6001\u6027\uff0c\u5bf9\u7236\u7c7b\u7684\u51fd\u6570\u8fdb\u884c\u91cd\u65b0\u5b9a\u4e49\u3002\u5982\u679c\u5728\u5b50\u7c7b\u4e2d\u5b9a\u4e49\u67d0\u65b9\u6cd5\u4e0e\u5176\u7236\u7c7b\u6709\u76f8\u540c\u7684\u540d\u79f0\u548c\u53c2\u6570\uff0c\u6211\u4eec\u8bf4\u8be5\u65b9\u6cd5\u88ab\u91cd\u5199 (Overriding)\u3002\u5728Java\u4e2d\uff0c\u5b50\u7c7b\u53ef\u7ee7\u627f\u7236\u7c7b\u4e2d\u7684\u65b9\u6cd5\uff0c\u800c\u4e0d\u9700\u8981\u91cd\u65b0\u7f16\u5199\u76f8\u540c\u7684\u65b9\u6cd5\u3002<\/span><\/p>\n

\u4f46\u6709\u65f6\u5b50\u7c7b\u5e76\u4e0d\u60f3\u539f\u5c01\u4e0d\u52a8\u5730\u7ee7\u627f\u7236\u7c7b\u7684\u65b9\u6cd5\uff0c\u800c\u662f\u60f3\u4f5c\u4e00\u5b9a\u7684\u4fee\u6539\uff0c\u8fd9\u5c31\u9700\u8981\u91c7\u7528\u65b9\u6cd5\u7684\u91cd\u5199\u3002<\/span><\/p>\n

\u65b9\u6cd5\u91cd\u5199\u53c8\u79f0\u65b9\u6cd5\u8986\u76d6\u3002<\/span><\/p>\n

    \uff082\uff09\u82e5\u5b50\u7c7b\u4e2d\u7684\u65b9\u6cd5\u4e0e\u7236\u7c7b\u4e2d\u7684\u67d0\u4e00\u65b9\u6cd5\u5177\u6709\u76f8\u540c\u7684\u65b9\u6cd5\u540d\u3001\u8fd4\u56de\u7c7b\u578b\u548c\u53c2\u6570\u8868\uff0c\u5219\u65b0\u65b9\u6cd5\u5c06\u8986\u76d6\u539f\u6709\u7684\u65b9\u6cd5\u3002<\/span><\/p>\n

\u5982\u9700\u7236\u7c7b\u4e2d\u539f\u6709\u7684\u65b9\u6cd5\uff0c\u53ef\u4f7f\u7528super\u5173\u952e\u5b57\uff0c\u8be5\u5173\u952e\u5b57\u5f15\u7528\u4e86\u5f53\u524d\u7c7b\u7684\u7236\u7c7b\u3002<\/span><\/p>\n

    \uff083\uff09\u5b50\u7c7b\u51fd\u6570\u7684\u8bbf\u95ee\u4fee\u9970\u6743\u9650\u4e0d\u80fd\u5c11\u4e8e\u7236\u7c7b\u7684\uff1b<\/span>
    \u4e0b\u9762\u662f\u91cd\u5199\u7684\u4f8b\u5b50\uff1a<\/span><\/p>\n

    \u6982\u5ff5\uff1a\u5373\u8c03\u7528\u5bf9\u8c61\u65b9\u6cd5\u7684\u673a\u5236\u3002<\/span><\/p>\n

 <\/p>\n

    \u52a8\u6001\u7ed1\u5b9a<\/strong>\u7684\u5185\u5e55\uff1a<\/span><\/p>\n

    1\u3001\u7f16\u8bd1\u5668\u68c0\u67e5\u5bf9\u8c61\u58f0\u660e\u7684\u7c7b\u578b\u548c\u65b9\u6cd5\u540d\uff0c\u4ece\u800c\u83b7\u53d6\u6240\u6709\u5019\u9009\u65b9\u6cd5\u3002\u8bd5\u7740\u628a\u4e0a\u4f8bBase\u7c7b\u7684test\u6ce8\u91ca\u6389\uff0c\u8fd9\u65f6\u518d\u7f16\u8bd1\u5c31\u65e0\u6cd5\u901a\u8fc7\u3002<\/span><\/p>\n

 <\/p>\n

    2\u3001\u91cd\u8f7d\u51b3\u7b56\uff1a\u7f16\u8bd1\u5668\u68c0\u67e5\u65b9\u6cd5\u8c03\u7528\u7684\u53c2\u6570\u7c7b\u578b\uff0c\u4ece\u4e0a\u8ff0\u5019\u9009\u65b9\u6cd5\u9009\u51fa\u552f\u4e00\u7684\u90a3\u4e00\u4e2a\uff08\u5176\u95f4\u4f1a\u6709\u9690\u542b\u7c7b\u578b\u8f6c\u5316\uff09\u3002<\/span><\/p>\n

\u5982\u679c\u7f16\u8bd1\u5668\u627e\u5230\u591a\u4e8e\u4e00\u4e2a\u6216\u8005\u6ca1\u627e\u5230\uff0c\u6b64\u65f6\u7f16\u8bd1\u5668\u5c31\u4f1a\u62a5\u9519\u3002\u8bd5\u7740\u628a\u4e0a\u4f8bBase\u7c7b\u7684test(byte b)\u6ce8\u91ca\u6389\uff0c\u8fd9\u65f6\u8fd0\u884c\u7ed3\u679c\u662f1 1\u3002<\/span><\/p>\n

 <\/p>\n

    3\u3001\u82e5\u65b9\u6cd5\u7c7b\u578b\u4e3apriavte static final \uff0cjava\u91c7\u7528\u9759\u6001\u7f16\u8bd1\uff0c\u7f16\u8bd1\u5668\u4f1a\u51c6\u786e\u77e5\u9053\u8be5\u8c03\u7528\u54ea<\/span>
    \u4e2a\u65b9\u6cd5\u3002<\/span><\/p>\n

 <\/p>\n

    4\u3001\u5f53\u7a0b\u5e8f\u8fd0\u884c\u5e76\u4e14\u4f7f\u7528\u52a8\u6001\u7ed1\u5b9a\u6765\u8c03\u7528\u4e00\u4e2a\u65b9\u6cd5\u65f6\uff0c\u90a3\u4e48\u865a\u62df\u673a\u5fc5\u987b\u8c03\u7528\u5bf9\u8c61\u7684\u5b9e\u9645\u7c7b\u578b\u76f8\u5339\u914d\u7684\u65b9\u6cd5\u7248\u672c\u3002<\/span><\/p>\n

\u5728\u4f8b\u5b50\u4e2d\uff0cb\u6240\u6307\u5411\u7684\u5b9e\u9645\u7c7b\u578b\u662fTestOverriding\uff0c\u6240\u4ee5b.test(0)\u8c03\u7528\u5b50\u7c7b\u7684test\u3002<\/span><\/p>\n

\u4f46\u662f\uff0c\u5b50\u7c7b\u5e76\u6ca1\u6709\u91cd\u5199test(byte b)\uff0c\u6240\u4ee5b.test((byte)0)\u8c03\u7528\u7684\u662f\u7236\u7c7b\u7684test(byte b)\u3002<\/span><\/p>\n

\u5982\u679c\u628a\u7236\u7c7b\u7684(byte b)\u6ce8\u91ca\u6389\uff0c\u5219\u901a\u8fc7\u7b2c\u4e8c\u6b65\u9690\u542b\u7c7b\u578b\u8f6c\u5316\u4e3aint,\u6700\u7ec8\u8c03\u7528\u7684\u662f\u5b50\u7c7b\u7684test(int i)\u3002<\/span><\/p>\n

 <\/p>\n

\u5b66\u4e60\u603b\u7ed3<\/strong>\uff1a<\/span><\/p>\n

    \u591a\u6001\u6027\u662f\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7684\u4e00\u79cd\u7279\u6027\uff0c\u548c\u65b9\u6cd5\u65e0\u5173\uff0c<\/span>
    \u7b80\u5355\u8bf4\uff0c\u5c31\u662f\u540c\u6837\u7684\u4e00\u4e2a\u65b9\u6cd5\u80fd\u591f\u6839\u636e\u8f93\u5165\u6570\u636e\u7684\u4e0d\u540c\uff0c\u505a\u51fa\u4e0d\u540c\u7684\u5904\u7406\uff0c\u5373\u65b9\u6cd5\u7684<\/span>
    \u91cd\u8f7d\u2014\u2014\u6709\u4e0d\u540c\u7684\u53c2\u6570\u5217\u8868\uff08\u9759\u6001\u591a\u6001\u6027\uff09<\/span><\/p>\n

\u3000 \u800c\u5f53\u5b50\u7c7b\u7ee7\u627f\u81ea\u7236\u7c7b\u7684\u76f8\u540c\u65b9\u6cd5\uff0c\u8f93\u5165\u6570\u636e\u4e00\u6837\uff0c\u4f46\u8981\u505a\u51fa\u6709\u522b\u4e8e\u7236\u7c7b\u7684\u54cd\u5e94\u65f6\uff0c\u4f60\u5c31\u8981\u8986\u76d6\u7236\u7c7b\u65b9\u6cd5\uff0c<\/span><\/p>\n

    \u5373\u5728\u5b50\u7c7b\u4e2d\u91cd\u5199\u8be5\u65b9\u6cd5\u2014\u2014\u76f8\u540c\u53c2\u6570\uff0c\u4e0d\u540c\u5b9e\u73b0\uff08\u52a8\u6001\u591a\u6001\u6027\uff09<\/span><\/p>\n

 <\/p>\n

    OOP\u4e09\u5927\u7279\u6027\uff1a\u7ee7\u627f\uff0c\u591a\u6001\uff0c\u5c01\u88c5\u3002<\/strong><\/span><\/p>\n

    public class Base<\/span>
    {
\n <\/span>
        void test(int i)<\/span>
        {
\n <\/span>
            System.out.print(i);<\/span>
        }<\/span>
        void test(byte b)<\/span>
        {
\n <\/span>
            System.out.print(b);<\/span>
        }<\/span>
    }<\/span>
    public class TestOverriding extends Base<\/span>
    {
\n <\/span>
        void test(int i)<\/span>
        {
\n <\/span>
            i++;<\/span>
            System.out.println(i);<\/span>
        }<\/span>
          public static void main(String[]agrs)<\/span>
        {
\n <\/span>
            Base b=new TestOverriding();<\/span>
            b.test(0)<\/span>
            b.test((byte)0)<\/span>
        }<\/span>
    }<\/span><\/p>\n

    \u8fd9\u65f6\u7684\u8f93\u51fa\u7ed3\u679c\u662f1     0\uff0c\u8fd9\u662f\u8fd0\u884c\u65f6\u52a8\u6001\u7ed1\u5b9a\u7684\u7ed3\u679c\u3002<\/span><\/p>\n

 <\/p>\n

\u91cd\u5199\u7684\u4e3b\u8981\u4f18\u70b9<\/strong>\u662f\u80fd\u591f\u5b9a\u4e49\u67d0\u4e2a\u5b50\u7c7b\u7279\u6709\u7684\u7279\u5f81\uff1a<\/span><\/p>\n

public class Father{
\n <\/span><\/p>\n

   public void speak(){
\n <\/span><\/p>\n

       System.out.println(Father);<\/span><\/p>\n

    }<\/span><\/p>\n

}<\/span><\/p>\n

public class Son extends Father{
\n <\/span><\/p>\n

    public void speak(){
\n <\/span><\/p>\n

        System.out.println(\"son\");<\/span><\/p>\n

   }<\/span><\/p>\n

}<\/span><\/p>\n

\u8fd9\u4e5f\u53eb\u505a\u591a\u6001\u6027\uff0c\u91cd\u5199\u65b9\u6cd5\u53ea\u80fd\u5b58\u5728\u4e8e\u5177\u6709\u7ee7\u627f\u5173\u7cfb\u4e2d\uff0c\u91cd\u5199\u65b9\u6cd5\u53ea\u80fd\u91cd\u5199\u7236\u7c7b\u975e\u79c1\u6709\u7684\u65b9\u6cd5\u3002<\/span><\/p>\n

\u5f53\u4e0a\u4f8b\u4e2dFather\u7c7bspeak()\u65b9\u6cd5\u88abprivate\u65f6\uff0cSon\u7c7b\u4e0d\u80fd\u91cd\u5199\u51faFather\u7c7bspeak()\u65b9\u6cd5\uff0c\u6b64\u65f6Son\u7c7bspeak()\u65b9\u6cd5\u76f8\u5f53\u4e0e\u5728Son\u7c7b\u4e2d\u5b9a\u4e49\u7684\u4e00\u4e2aspeak()\u65b9\u6cd5\u3002<\/span><\/p>\n

Father\u7c7bspeak()\u65b9\u6cd5\u4e00\u4f46\u88abfinal\u65f6\uff0c\u65e0\u8bba\u8be5\u65b9\u6cd5\u88abpublic,protected\u53ca\u9ed8\u8ba4\u6240\u4fee\u9970\u65f6\uff0cSon\u7c7b\u6839\u672c\u4e0d\u80fd\u91cd\u5199Father\u7c7bspeak()\u65b9\u6cd5\uff0c<\/span><\/p>\n

\u8bd5\u56fe\u7f16\u8bd1\u4ee3\u7801\u65f6\uff0c\u7f16\u8bd1\u5668\u4f1a\u62a5\u9519\u3002\u4f8b\uff1a<\/span><\/p>\n

public class Father{
\n <\/span><\/p>\n

   final public void speak(){
\n <\/span><\/p>\n

       System.out.println(\"Father\");<\/span><\/p>\n

    }<\/span><\/p>\n

}<\/span><\/p>\n

public class Son extends Father{
\n <\/span><\/p>\n

    public void speak(){
\n <\/span><\/p>\n

       System.out.println(\"son\");<\/span><\/p>\n

    }<\/span><\/p>\n

}       \/\/\u7f16\u8bd1\u5668\u4f1a\u62a5\u9519\uff1b<\/span><\/p>\n

 <\/p>\n

Father\u7c7bspeak()\u65b9\u6cd5\u88ab\u9ed8\u8ba4\u4fee\u9970\u65f6\uff0c\u53ea\u80fd\u5728\u540c\u4e00\u5305\u4e2d\uff0c\u88ab\u5176\u5b50\u7c7b\u88ab\u91cd\u5199\uff0c\u5982\u679c\u4e0d\u5728\u540c\u4e00\u5305\u5219\u4e0d\u80fd\u91cd\u5199\u3002<\/span><\/p>\n

Father\u7c7bspeak()\u65b9\u6cd5\u88abprotoeted\u65f6\uff0c\u4e0d\u4ec5\u5728\u540c\u4e00\u5305\u4e2d\uff0c\u88ab\u5176\u5b50\u7c7b\u88ab\u91cd\u5199\uff0c\u8fd8\u53ef\u4ee5\u4e0d\u540c\u5305\u7684\u5b50\u7c7b\u91cd\u5199\u3002<\/span><\/p>\n

 <\/p>\n

\u91cd\u5199\u65b9\u6cd5\u7684\u89c4\u5219<\/span><\/strong>\uff1a<\/span><\/p>\n

1\u3001\u53c2\u6570\u5217\u8868\u5fc5\u987b\u5b8c\u5168\u4e0e\u88ab\u91cd\u5199\u7684\u65b9\u6cd5\u76f8\u540c\uff0c\u5426\u5219\u4e0d\u80fd\u79f0\u5176\u4e3a\u91cd\u5199\u800c\u662f\u91cd\u8f7d\u3002<\/span><\/p>\n

2\u3001\u8fd4\u56de\u7684\u7c7b\u578b\u5fc5\u987b\u4e00\u76f4\u4e0e\u88ab\u91cd\u5199\u7684\u65b9\u6cd5\u7684\u8fd4\u56de\u7c7b\u578b\u76f8\u540c\uff0c\u5426\u5219\u4e0d\u80fd\u79f0\u5176\u4e3a\u91cd\u5199\u800c\u662f\u91cd\u8f7d\u3002<\/span><\/p>\n

3\u3001\u8bbf\u95ee\u4fee\u9970\u7b26\u7684\u9650\u5236\u4e00\u5b9a\u8981\u5927\u4e8e\u88ab\u91cd\u5199\u65b9\u6cd5\u7684\u8bbf\u95ee\u4fee\u9970\u7b26\uff08public>protected>default>private\uff09<\/span><\/p>\n

4\u3001\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\u3002\u4f8b\u5982\uff1a<\/span><\/p>\n

\u7236\u7c7b\u7684\u4e00\u4e2a\u65b9\u6cd5\u7533\u660e\u4e86\u4e00\u4e2a\u68c0\u67e5\u5f02\u5e38IOException\uff0c\u5728\u91cd\u5199\u8fd9\u4e2a\u65b9\u6cd5\u662f\u5c31\u4e0d\u80fd\u629b\u51faException,\u53ea\u80fd\u629b\u51faIOException\u7684\u5b50\u7c7b\u5f02\u5e38\uff0c\u53ef\u4ee5\u629b\u51fa\u975e\u68c0\u67e5\u5f02\u5e38\u3002<\/span><\/p>\n

 <\/p>\n

\u800c\u91cd\u8f7d\u7684\u89c4\u5219\uff1a<\/span><\/strong><\/span><\/p>\n

1\u3001\u5fc5\u987b\u5177\u6709\u4e0d\u540c\u7684\u53c2\u6570\u5217\u8868\uff1b<\/span><\/p>\n

2\u3001\u53ef\u4ee5\u6709\u4e0d\u8d23\u9a82\u7684\u8fd4\u56de\u7c7b\u578b\uff0c\u53ea\u8981\u53c2\u6570\u5217\u8868\u4e0d\u540c\u5c31\u53ef\u4ee5\u4e86\uff1b<\/span><\/p>\n

3\u3001\u53ef\u4ee5\u6709\u4e0d\u540c\u7684\u8bbf\u95ee\u4fee\u9970\u7b26\uff1b<\/span><\/p>\n

4\u3001\u53ef\u4ee5\u629b\u51fa\u4e0d\u540c\u7684\u5f02\u5e38\uff1b<\/span><\/p>\n

 \u53c2\u8003\u6587\u7ae0\uff1ahttp:\/\/www.cnblogs.com\/bluestorm\/archive\/2012\/03\/01\/2376236.html<\/p>\n

\u91cd\u5199\u4e0e\u91cd\u8f7d\u7684\u533a\u522b\u5728\u4e8e\uff1a<\/span><\/strong><\/span><\/p>\n

\u91cd\u5199\u591a\u6001\u6027\u8d77\u4f5c\u7528\uff0c\u5bf9\u8c03\u7528\u88ab\u91cd\u8f7d\u8fc7\u7684\u65b9\u6cd5\u53ef\u4ee5\u5927\u5927\u51cf\u5c11\u4ee3\u7801\u7684\u8f93\u5165\u91cf\uff0c\u540c\u4e00\u4e2a\u65b9\u6cd5\u540d\u53ea\u8981\u5f80\u91cc\u9762\u4f20\u9012\u4e0d\u540c\u7684\u53c2\u6570\u5c31\u53ef\u4ee5\u62e5\u6709\u4e0d\u540c\u7684\u529f\u80fd\u6216\u8fd4\u56de\u503c\u3002<\/span><\/p>\n

\u7528\u597d\u91cd\u5199\u548c\u91cd\u8f7d\u53ef\u4ee5\u8bbe\u8ba1\u4e00\u4e2a\u7ed3\u6784\u6e05\u6670\u800c\u7b80\u6d01\u7684\u7c7b\uff0c\u53ef\u4ee5\u8bf4\u91cd\u5199\u548c\u91cd\u8f7d\u5728\u7f16\u5199\u4ee3\u7801\u8fc7\u7a0b\u4e2d\u7684\u4f5c\u7528\u975e\u540c\u4e00\u822c.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"Java\u7684\u91cd\u8f7d\u548c\u91cd\u5199\u533a\u522b\uff08\u9762\u8bd5\u5e38\u89c1\uff09\u4eca\u5929\u5728\u770bC#\u7684\u57fa\u7840\u77e5\u8bc6\uff0c\u540c\u662f\u9762\u5411\u5bf9\u8c61\u7684\u8bed\u8a00\uff0c\u770b\u5230\u91cd\u8f7d\u548c\u91cd\u5199\uff0c\u6211\u7a81\u7136\u60f3\u4e86\u534a\u5929\uff0c\u6709\u70b9\u6a21\u7cca\u4e86...","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\/629"}],"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=629"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/629\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}