<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                >[success] # static * **static** 修飾`成員變量` 和 `成員方法`,修飾后屬于`類` 所有,分別叫做`靜態變量`,`靜態方法`,**static**修飾后只隨著**類的加載**準備就緒,與是否創建對象無關 * 使用上static關鍵字修飾的成員可以使用`引用.`的方式訪問,但推薦`類名.的`方式 >[danger] ##### 案例 * **非靜態成員方法**中既能訪問**非靜態的成員**又能訪問**靜態的成員**,`(成員:成員變量 + 成員方法, 靜態成員被所有對象共享)` * **靜態成員方法**中只能訪問靜態成員**不能訪問非靜態成員**。`(成員:成員變量 + 成員方法, 因為此時可能還沒有創建對象)` ~~~ public class StaticTest { private int a; // 聲明一個靜態變量 private static int b; public void setA(int a) { this.a = a; } public int getA() { return a; } // 靜態方法 public static int getB() { // 類. 屬性 return StaticTest.b; } // 靜態方法 public static void setB(int b) { // this.b = b // 報錯靜態方法可以直接類調用此時并沒有創建對象實例因此沒有this // 類. 屬性 StaticTest.b = b; } public void show() { // 在非靜態方法中可以通過this 調用靜態屬性 因為此時方法調用需要創建對象因此this存在 System.out.println(a + "," + this.b); System.out.println(a + "," + StaticTest.b); } public static void main(String[] args) { StaticTest staticTest = new StaticTest(); staticTest.setA(10); // 通過實列調用靜態方法 也可調用靜態屬性不推薦 staticTest.setB(11); staticTest.show(); // 10,11 // 創建新的實列 StaticTest staticTest1 = new StaticTest(); staticTest1.setA(10); // 靜態方法推薦類調用 StaticTest.setB(16); // 靜態屬性共享的此時 重新打印 都變成同一的 staticTest.show(); // 10,16 staticTest1.show(); // 10,16 } } ~~~ >[danger] ##### main -- 方法含義 * 公共的 靜態的 無返回值的 叫 main 的一個方法,并且可以接受一個數組字符串作為參數,傳參時候`java 文件 參數1 參數2` ~~~ public static void main(String[] args){} ~~~
                  <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>

                              哎呀哎呀视频在线观看