久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      java中的構(gòu)造函數(shù)與普通函數(shù)有什么區(qū)別

      java中的構(gòu)造函數(shù)與普通函數(shù)有什么區(qū)別

      構(gòu)造函數(shù)與普通函數(shù)的區(qū)別如下:

      1、寫法上的不同

      構(gòu)造方法:

      public(修飾符) class(定義類的關(guān)鍵字) Test(類名)(){     //無參     Test(類名)(){     }     //帶一個(gè)參數(shù)     Test(類名)(String(變量類型) name(變量名)){     } }

      (視頻教程推薦:java視頻)

      普通方法:

      //定義類 public(修飾符) class(定義類的關(guān)鍵字) Test(類名)(){     private(修飾符) static(修飾符) String(變量類型) s(變量名) = “hello world”;     //下面是方法的定義     public(修飾符) static(修飾符) void(返回值類型) main(方法名)(String[] args(參數(shù))){         System.out.println(s);(代碼語句)     } }

      2、在運(yùn)行上的不同

      構(gòu)造方法:

      構(gòu)造方法在創(chuàng)建的時(shí)候就給對(duì)象初始化; 一個(gè)對(duì)象建立構(gòu)造方法只能運(yùn)行一次;

      普通方法:

      一般方法是對(duì)象調(diào)用才執(zhí)行,給對(duì)象添加對(duì)象具備的功能; 一般方法可以被對(duì)象多次調(diào)用;

      推薦教程:java入門程序

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)