增强for循环讲解

package com.wuming.struct;

public class ForDemo05 {
    public static void main(String[] args) {
        //增强for循环
        //jdk5特性
        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);
        }
    }
}

10
20
30
40
50
===============
10
20
30
40
50

猜你喜欢

转载自blog.csdn.net/wanggang182007/article/details/121111156
今日推荐