|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- package PracticeStudent;
- public class PracticeStdent {
- public static void main(String[] args) {
- int[][] student = new int[20][2];
- for(int i = 0;i<student.length;i++) {
- student[i] = new int[]{i+1};
- student[i][0] = (int)(Math.random()*5+1);//state:1-5
- student[i][1] = (int)(Math.random()*26+75);//score:75-100
- }
- }
- }
复制代码
运行后,报错:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at Class/PracticeStudent.PracticeStdent.main(PracticeStdent.java:9)
求解答!
07行 改为 就好了
还有08,09行不对应该改为
- student[i][0] = (int)(Math.random()%5+1);//state:1-5
- student[i][1] = (int)(Math.random()%26+75);//score:75-100
复制代码
|
|