【发布时间】:2014-12-06 02:28:28
【问题描述】:
import java.util.Scanner;
public class TestMultiDimenArray
{
private static int row;
private static int column;
public static int [][] table1 = new int [row][column];
public static int [][] get ( int a, int b){
row = a;
column = b;
Scanner keyboard = new Scanner(System.in);
for (int n = 0; n < a; n++){
for (int m = 0; m < b; m++){
table1[n][m] = keyboard.nextInt();
}
}
return table1;
}
public static void display (int [][] array1){
for (int n = 0; n < row; n++){
for (int m = 0; m < column; m++){
System.out.print(table1[n][m] + " ");
}
System.out.println();
}
}
public static void main(String[] args){
get(3,3);
}
}
程序编译成功,但是当我运行它时,它返回错误。我该如何解决?这就是我能说的关于我的问题的全部内容。告诉我要提供更多细节的系统出了什么问题。
【问题讨论】:
-
您是否尝试调试过您的程序?你觉得你在用
public static int [][] table1 = new int [row][column];做什么?达到此语句时row和column的值是多少? Java 不是 Excel...
标签: java arrays runtime-error main