数组遍历

数组遍历

public class Test1 {
    public static void main(String[] args) {//数组遍历
        int[] a = {27,94,39,76,32,64,83};

        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }
        System.out.println("====================================");
        int i = 0;
        while (i<a.length){
            System.out.println(a[i]);
            i++;
        }
       //for循环和while循环都能遍历数组,for循环更简洁
    }
}

27
94
39
76
32
64
83
====================================
27
94
39
76
32
64
83

Process finished with exit code 0
posted @ 2022-04-29 22:34  追风的羊  阅读(32)  评论(0)    收藏  举报