使用java理解程式邏輯(5)

來源:互聯網
上載者:User

標籤:倒序輸出   理論   inpu   system.in   變數   ring   bre   匹配   har   

沒有(4)   我是按照章節來的,第四章沒什麼好整理的,注意一下

 

switch:1、只能作為等值判斷 2、只能匹配int和char

 

input.hasNextInt();判斷輸入值是否是數字 是數字返回true  不是數字返回false

 

調試3步驟:1、設定斷點 2、開始調試 3、觀察變數

 

equals:用於比較字串

Scanner input=new Scanner(System.in);

String ok="n";//預設老師不滿足

while(ok.equals("n")){

System.out.println("上午看理論");

System.out.println("下午敲代碼");

System.out.print("\n合格了嗎?y/n:");

ok=input.next();

}

System.out.println("合格了!");

 

while和do while迴圈:

while(條件){....} ==>while迴圈特點:先判斷 再執行
do{....}while(條件); ==>do..while迴圈特點:先執行 後判斷

 

倒序輸出:
int a=12345;
System.out.println(a);
while(a!=0){
int y=a%10;//1
System.out.print(y);//54321
a=a/10;//0
}

 

for(初始化;條件;累加、減){...}
for(1;2;4){    //執行的順序是:1234234234234234234234.....
3
}
for(int i=1;i<=100;i++){//101
System.out.println("第"+i+"次 好好學習!");
}

 

break:結束整個迴圈

continue:結束當前迴圈 直接進入下一次迴圈

使用java理解程式邏輯(5)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.