标签:== public static 代码 void min author nis length
增强for循环
格式:
for(声明语句:表达式){
//代码
}
/**
* @author Administrator
* @create 2021/2/27 22:46
*/
public class Demo05 {
public static void main(String[] args) {
//定义数组
int[] num = {10,20,30,40,50};
//普通for循环 遍历元素
for (int i = 0; i < num.length; i++) {
System.out.println(num[i]);
}
System.out.println("=====================");
//增强for循环,遍历数组的元素
for (int x:num) {
System.out.println(x);
}
}
}
标签:== public static 代码 void min author nis length
原文地址:https://www.cnblogs.com/lilizihaoye/p/14457604.html