增强for循环

 1 package struct;
 2 
 3 public class ForDemo05 {
 4     public static void main(String[] args) {
 5         int[] numbers = {10,20,30,40,50};//定义一个数组
 6         for (int i = 0; i < 5; i++) {
 7             System.out.println(numbers[i]);
 8         }
 9         System.out.println("===================");
10         //遍历数组中的元素
11         for (int x:numbers) {
12             System.out.println(x);
13         }
14     }
15 }

 

posted on 2022-07-21 16:27  一枚努力学习的小白  阅读(14)  评论(0编辑  收藏  举报