The following notes are based on the book: << Head First JAVA >> and video series: 手把手教你用Java基础教程 - 北京尚学堂 - 马士兵
- For loop
The process follows:
- execute ep1
- if ep2 is true, go to 3; otherwise break;
- execute statements
- execute ep3
- iterate again 2~4
1 | for (ep1; ep2; ep3){ |
- While loop
1 | while(ep){ |
- Do while loop
1 | //noteic the ';' after while!!! |
- If else
1 | if (ep1){} |
- Switch
- i must be int (char, short).
- if i = 8 , st1 is executed.
- case can dig through if
break
not existed. ex. if i = 10, st3 and st4 are executed. - default is used to handle no-match.
1 | //example |