1. 程式人生 > >循環語句

循環語句

color blog div 一維數組 foreach語句 遍歷 code pan 數組

包括:while、do…while、for

for(數據類型 x:遍歷對象){ } (此語法格式成為foreach語句,用於遍歷數組)

        int arr[] = { 7, 10, 1 };// 一維數組
        System.out.println("一維數組的元素為:");
        for (int x : arr) {      //foreach語句
            System.out.print(x + "\t");
        }

循環語句