0
配列について
配列について
テキスト通り入力すると。
class Sample044
{
public static void main(String[]args)
{
int[] test;
test = new int[5];
test[0] = 80;
test[1] = 60;
test[2] = 22;
test[3] = 50;
test[4] = 75;
for(int i=0; i<= 5; i++){
System.out.println((i +1)+ "何番目の人の点数は"+
test[i]+"です。");
}
}
}
で、
出力結果は
C:\javaSample>java Sample044
1何番目の人の点数は80です。
2何番目の人の点数は60です。
3何番目の人の点数は22です。
4何番目の人の点数は50です。
5何番目の人の点数は75です。
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at Sample044.main(Sample044.java:15)
となります。
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at Sample044.main(Sample044.java:15)
は何で出力されるのでしょうか?