처음에는 내 게시물을 볼 시간을내어 주셔서 감사합니다. 기본적으로 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());
}
}
크기가 테이블 [i] [j]를 초기화하지 않았습니까? – kosa