<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之旅 廣告
                [toc] # switch switch 語句相當于 if else的另一種表達方式 ~~~ public class HelloWorld { public static void main(String[] args) { //如果使用if else int day = 5; if (day==1) System.out.println("星期一"); else if (day==2) System.out.println("星期二"); else if (day==3) System.out.println("星期三"); else if (day==4) System.out.println("星期四"); else if (day==5) System.out.println("星期五"); else if (day==6) System.out.println("星期六"); else if (day==7) System.out.println("星期天"); else System.out.println("這個是什么鬼?"); //如果使用switch switch(day){ case 1: System.out.println("星期一"); break; case 2: System.out.println("星期二"); break; case 3: System.out.println("星期三"); break; case 4: System.out.println("星期四"); break; case 5: System.out.println("星期五"); break; case 6: System.out.println("星期六"); break; case 7: System.out.println("星期天"); break; default: System.out.println("這個是什么鬼?"); } } } ~~~ # continue 循環里遇到continue不執行后面的語句直接進行下一次循環 ~~~ public class HelloWorld { public static void main(String[] args) { //打印單數 for (int j = 0; j < 10; j++) { if(0==j%2) continue; //如果是雙數,后面的代碼不執行,直接進行下一次循環 System.out.println(j); } } } ~~~ 結果: ![](https://box.kancloud.cn/72963e04545766e314bed319b050a3d7_54x99.png) <br> # break 循環中遇見break直接跳出循環 # 打印菱形 ![](https://img.kancloud.cn/b7/65/b76514845a56b32c3ec0f936342fb974_104x141.png) 打印如圖所示菱形,第一步是發現對稱關系,然后將此圖形分開看,先打上部分,下半部分由對稱性很好畫出。 ![](https://img.kancloud.cn/4e/69/4e69cc7abfe02f39f22fd817c840c58a_75x214.png) 第二步找到要打印的<b>空格、*和行號</b>的關系,不妨設行號為i,空格為j,星號為z 很容易找到關系 j=4-i,z=2i-1 ~~~ public static void main(String[] args) { // 外層的for循環,i是行號 for (int i = 1; i <= 4; i++) { // 打印空格 for (int j = 1; j <= 4 - i; j++) { System.out.print(" "); } // 打印* for (int z = 1; z <= 2 * i - 1; z++) { System.out.print("*"); } // 換行 System.out.println(); } // 把上面打印的倒過來,再去掉i=4的那一行 for (int i = 3; i >= 1; i--) { for (int j = 1; j <= 4 - i; j++) { System.out.print(" "); } for (int z = 1; z <= 2 * i - 1; z++) { System.out.print("*"); } System.out.println(); } } ~~~ # 打印乘法表 ~~~ public static void main(String[] args) { //外循環控制行數 for(int i=1;i<10;i++) { //內循環控制列數 for(int j=1;j<=i;j++) { System.out.print(j+"*"+i+"="+(j*i)+"\t"); } System.out.println(); } } ************************************ 運行結果 1*1=1 1*2=2 2*2=4 1*3=3 2*3=6 3*3=9 1*4=4 2*4=8 3*4=12 4*4=16 1*5=5 2*5=10 3*5=15 4*5=20 5*5=25 1*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36 1*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49 1*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64 1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81 ~~~
                  <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>

                              哎呀哎呀视频在线观看