for (int x : number)

增强型的for循环

主要用来处理数组或集合的循环

package com.scanner;

public class Demo08 {
    public static void main(String[] args){
        int[] number = {10, 20, 30, 40, 50};    //定义了一个数组
        for (int x:number){
            System.out.println(x);
        }
    }
}
posted @ 2024-09-11 17:39  lo星空物语ol  阅读(15)  评论(0)    收藏  举报