3C科技 娛樂遊戲 美食旅遊 時尚美妝 親子育兒 生活休閒 金融理財 健康運動 寰宇綜合

Zi 字媒體

2017-07-25T20:27:27+00:00
加入好友
jash.liao的JAVA整理教學:JAVA控制結構-多重選擇結構(switch)    線上執行:http://www.tutorialspoint.com/compile_java_online.php / http://www.compilejava.net/ code2html:http://tohtml.com/   publicclass HelloWorld{     /*C語言的switch只能數字,JAVA比較靈活*/     publicstaticvoid main(String[]args){         String saying ="Never put off till tomorrow what you can do today.";         int aV, eV, iV, oV, uV, other, i;         aV = eV = iV = oV = uV = other = i =0;                   while(saying.charAt(i)!='.'){             switch(saying.charAt(i)){                 case'A':                 case'a':                     aV++;                     break;                                  case'E':                case'e':                     eV++;                     break;                                  case'I':                 case'i':                     iV++;                     break;                              case'O':                 case'o':                     oV++;                     break;                              case'U':                 case'u':                     uV++;                     break;                                  default:                     other++;                     break;             }                      i++;         }         System.out.println("a: "+ aV +", e: "+ eV +", i: "+ iV +", o: "+ oV +", u: "+ uV +", other: "+ other);     } }        

本文由jashliaoeuwordpress提供 原文連結

寫了 5860316篇文章,獲得 23313次喜歡
精彩推薦