package com.lyc.struct;
public class ForDemo05 {
public static void main(String[] args) {
int[] numbers = {10,20,30,40,50,60} ;
//遍历数组的结果
//把numbers里的结果遍历出来赋值给了x,x就是默认的numbers中的每一个数字,每次循环就从numbers中取值
for (int x : numbers){
System.out.println(x);
}
/*
相当于上面的代码
for(int i = 0; i < 5; i++){
System.out.println(numbers[i]);
}
*/
}
}
原文:https://www.cnblogs.com/liuyunche/p/14243591.html