<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                1.構造代碼塊 ~~~ package obj.b1; public class Test { public static void main(String[] args) { Person p1 =new Person(); Person p2 =new Person("小李"); } } /* * 對象一建立就運行了,而且優先于構造函數執行 * 給對象進行初始化的 * 構造代碼塊和構造方法的區別: * 構造方法是對應的對象進行初始化, * 構造代碼塊是給所有的對象進行統一的初始化 * 構造代碼塊中定義是不用對象共性的初始化內容 * * */ class Person{ String name; Person(){ System.out.println("我是無參構造方法"); } Person(String name){ System.out.println("我是有參構造方法"); } { System.out.println("我是構造代碼塊"); } } ~~~ ![](https://box.kancloud.cn/53e7806b35b54eb450fc3ef6bde5c11a_170x133.png) 2.構造方法之間的調用 ~~~ package obj.b2; public class Test { public static void main(String[] args) { Student s=new Student("小明",2); } } /* * this:看上去,用來區分局部變量和成員變量同名的情況 * this:就是代表本類對象,this代表它所在函數(方法)所屬對象的引用 * 構造函數之間的調用只能通過this語句來完成 * 構造函數之間進行調用時,this語句只能出現在第一行,構造方法要先執行, * 如果初始化當中還有初始化,那就去執行更細節的初始化 * */ class Student{ String name; int age; Student(){ System.out.println("無參構造方法"); } Student(String name){ this(); this.name=name; System.out.println("aaa"); } Student(String name,int age){ this(name); this.age=age; } } ~~~ ![](https://box.kancloud.cn/36467009771d27c02ae44940df8c7e92_299x83.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看