我不知道这个错误意味着什么:
线程中的异常" main"显示java.lang.NullPointerException 在Untitled.main(Untitled.java:16)
class Untitled {
public static void main(String[] args) {
int x=3;
int y=5;
double d=0;
int[][] route = new int[][]{
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
{ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 },
{ 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 },
{ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 },
{ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50 }
};
int[][] distance = new int[10][];
for (int i=0;i<route.length;i++) {
for (int j=0;j<route[0].length;j++) {
distance[i][j]=route[i][j]-x;
}
}
}
}
答案 0 :(得分:0)
您定义的二维数组错误。
变化
int[][] distance = new int[10][];
与
int[][] distance = new int[5][10];