package com.xiyue.struct;public class ForDemo04 { public static void main(String[] args) { for (int i = 1; i <= 9; i++) { for (int j = 1; j <=i; j++) { System.out.print(j+"*"+i+"="+i*j+"t"); } System.out.println(); } }}
2.初识增强For循环增强for循环就是把for循环写得更简洁一点。
package com.xiyue.struct;public class ForDemo05 { public static void main(String[] args) { int[] numbers={10,20,30,40,50};//定义了一个数组 for (int i=0;i<5;i++){ System.out.println(numbers[i]); } System.out.println("==========================="); //遍历数组的元素 for(int x:numbers){ System.out.println(x); } }}
循环结构知识点整理