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

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # Java 中的`do-while`循環 > 原文: [https://beginnersbook.com/2015/03/do-while-loop-in-java-with-example/](https://beginnersbook.com/2015/03/do-while-loop-in-java-with-example/) 在上一個教程中,我們討論了[`while`循環](https://beginnersbook.com/2015/03/while-loop-in-java-with-examples/)。在本教程中,我們將討論 java 中的`do-while`循環。`do-while`循環類似于`while`循環,但是它們之間存在差異:在`while`循環中,在執行循環體之前求值條件,但是在執行循環體之后求值`do-while`循環條件。 #### `do-while`循環的語法: ```java do { statement(s); } while(condition); ``` ## `do-while`循環如何工作? 首先,循環內的語句執行,然后條件得到求值,如果條件返回`true`,則控制流轉移到`do`,否則它會在`do-while`之后跳轉到下一個語句。 ![do while loop java](https://img.kancloud.cn/c5/33/c533f6827cfa61e8d65e460440677b4e_400x400.jpg) ## `do-while`循環示例 ```java class DoWhileLoopExample { public static void main(String args[]){ int i=10; do{ System.out.println(i); i--; }while(i>1); } } ``` **輸出:** ```java 10 9 8 7 6 5 4 3 2 ``` ## 示例:使用`do-while`循環迭代數組 這里我們有一個整數數組,我們正在迭代數組并使用`do-while`循環顯示每個元素。 ```java class DoWhileLoopExample2 { public static void main(String args[]){ int arr[]={2,11,45,9}; //i starts with 0 as array index starts with 0 int i=0; do{ System.out.println(arr[i]); i++; }while(i<4); } } ``` 輸出: 2 11 45 9
                  <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>

                              哎呀哎呀视频在线观看