配列の各要素に先頭から順に 1,2,3,4 を代入して表示 (初期化子の足りない要素)

明解C言語 入門編 > 5. 配列 >

配列の各要素に先頭から順に 1,2,3,4 を代入して表示 (初期化子の足りない要素)

Java
class Lesson032 {
    public static void main(String[] args) {
        int[] score = {1, 2, 3, 4, 5};

        for (int i = 0; i < 5; i++)
            System.out.printf("点数%d = %d\n", i + 1, score[i]);
    }
}

実行結果

L:\>java Lesson032
点数1 = 1
点数2 = 2
点数3 = 3
点数4 = 4
点数5 = 5