0
       int x = 0;
       int y = 0;       
        /**modify grade*/
        Scanner student = new Scanner(System.in);             
        System.out.print("Enter student ID:");
        int studentId = student.nextInt();

        switch (studentId){
        case 1101:
            Scanner course = new Scanner(System.in);              
            System.out.print("Enter course ID:");
            int courseID = course.nextInt();

            switch(courseID){
            case 901:
                x = 1;
                y = 1;

                Scanner change = new Scanner(System.in);              
                System.out.print("Enter new value:");
                int newGrade = change.nextInt();

                aryTable[x][y] = newGrade;//problem here

                break;

            break;
        }

用“新品级”;它有一个红色下划线表示类型不匹配,但一切似乎都很好,即使是以前使用的 2 台扫描仪也能正常工作。这只是一个复制粘贴,我很困惑为什么这是错误的?我可以得到任何帮助以使其有效吗?我正在制作一个程序,该程序将获取学生,然后获取课程,然后修改相应的成绩..我使用了二维数组..谢谢和欢呼

4

2 回答 2

2

无论您在做什么都是不正确的,这不是初始化或使用多维数组的方式。试试下面的代码,

x=1;
y=1;    
int aryTable[][]=new int[x][y];    
aryTable[0][x-1]=newGrade;
于 2013-08-08T08:04:49.930 回答
0

像这样定义数组表。

int[][] arrayTable;

问题是您将 int 值分配给另一种类型的二维数组。

于 2013-08-08T07:56:40.950 回答