for循环的使用
-
关于换行
- print输出后不换行
- println输出后换行
-
打印九九乘法表代码样例
package com.li.forExercise; public class forExercise { public static void main(String[] args) { for (int i = 1; i <= 9; i++) { for (int j = 1; j <= i; j++) { System.out.print(i+"*"+j+"="+(i*j)+"\t"); } System.out.println(); } } }
-
增强for循环
package com.li.forExercise; public class forStrong { public static void main(String[] args) { int[] num = {1,2,3,4,5,6}; for(int x:num) System.out.println(x); } }