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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Java 程序:找到三個數字中最大的一個 > 原文: [https://beginnersbook.com/2017/09/java-program-to-find-largest-of-three-numbers/](https://beginnersbook.com/2017/09/java-program-to-find-largest-of-three-numbers/) 在這里,我們將編寫兩個 java 程序來查找三個數字中最大的程序。 1)使用`if-else..if`2)使用嵌套的`If` 要了解這些程序,您應該掌握 Java 中[`if..else-if`語句](https://beginnersbook.com/2017/08/if-else-statement-in-java/)的知識。如果您是 java 新手,請從[核心 Java 教程](https://beginnersbook.com/java-tutorial-for-beginners-with-examples/)開始。 ## 示例 1:使用`if-else..if`查找三個數字中的最大數字 ```java public class JavaExample{ public static void main(String[] args) { int num1 = 10, num2 = 20, num3 = 7; if( num1 >= num2 && num1 >= num3) System.out.println(num1+" is the largest Number"); else if (num2 >= num1 && num2 >= num3) System.out.println(num2+" is the largest Number"); else System.out.println(num3+" is the largest Number"); } } ``` 輸出: ```java 20 is the largest Number ``` ## 示例 2:使用嵌套`if`在三個數字中查找最大數字 ```java public class JavaExample{ public static void main(String[] args) { int num1 = 10, num2 = 20, num3 = 7; if(num1 >= num2) { if(num1 >= num3) /* This will only execute if conditions given in both * the if blocks are true, which means num1 is greater * than num2 and num3 */ System.out.println(num1+" is the largest Number"); else /* This will only execute if the condition in outer if * is true and condition in inner if is false. which * means num1 is grater than num2 but less than num3. * which means num3 is the largest */ System.out.println(num3+" is the largest Number"); } else { if(num2 >= num3) /* This will execute if the condition in outer if is false * and inner if is true which means num3 is greater than num1 * but num2 is greater than num3\. That means num2 is largest */ System.out.println(num2+" is the largest Number"); else /* This will execute if the condition in outer if is false * and inner if is false which means num3 is greater than num1 * and num2\. That means num3 is largest */ System.out.println(num3+" is the largest Number"); } } } ``` 輸出: ```java 20 is the largest Number ```
                  <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>

                              哎呀哎呀视频在线观看