01. Java条件语句之 if
02. Java条件语句之 if...else
03. Java条件语句之 多重if
04. Java条件语句之 嵌套if
05. Java条件语句之 switch
06. Java循环语句之 while:先判断,后执行
07. Java循环语句之 do...while:先执行,后判断(至少执行一次)
08. Java循环语句之 for
package imooc; public class practice { public static void main(String[] args) { //normal test for (int a=1; a<=5; a++) { System.out.println("a"); } //omit initialization of variable int b=1; for ( ; b<=5; b++) { System.out.println("b"); } //omit condition -> endless loop //for (int c=1; ; c++) { // System.out.println("c"); //} //omit changing of variable for (int d=1; d<=5; ) { System.out.println("d"); d++; } //multiple variables for (int e=1,f=2; e<=5; e++,f--) { System.out.println(e+"+"+f+"="+(e+f)); } } }
09. Java循环跳转语句之 break:退出指定循环
10. Java循环跳转语句之 continue:跳过循环体中剩余语句,执行下一次循环
11. Java循环语句之 多重循环
package imooc; public class practice { public static void main(String[] args) { System.out.println("right triangle"); for(int i=1; i<=3; i++) { for(int j=1; j<=i; j++) { System.out.print("*"); } System.out.println(); } } }
12. Practice:Judge digits
package imooc; public class practice { public static void main(String[] args) { int num = 999; int count=1; for (count=1; (num/=10)!=0; count++); System.out.println(count); } }