增强For循环

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

 

posted @ 2021-03-23 15:31  HeartlessHero  阅读(24)  评论(0)    收藏  举报