public class Testex
{
public static void main ( String[] args ) {
double [] scores = new double [5];
scores [5] = 95.75;
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道这里抛出了什么异常,请帮忙
这将是一个Index Out Of Range Exception(数组基于0,而不是基于1):
scores[5] = 95.75; // references the sixth element of a five element array
Run Code Online (Sandbox Code Playgroud)