我最初想说谢谢你花时间看我的帖子。基本上,我尝试使用 Math.random 创建一个带有随机整数的多维数组。代码编译并不断返回空指针异常错误消息。我不知道我在创建对象时做错了什么。谁能告诉我代码有什么问题?
public Table(int r, int c)
{
rows = r;
columns = c;
for (int i = 0; i < r; i++)
for (int j = 0; j < c; j++)
{
/*
* Here is where the error keeps returning, blueJ keeps pointing
* me to this line of code and it has to be the variables I am using
* in the array that are causing the issue. The only issue is I * don't know what to insert for that.
*/
theTable[i][j] = (int)(100*Math.random());
}
}