-1
所以我有一個2d數組,我在測試程序類中創建,然後我試圖發送它並在構造函數中創建一個副本,但得到一個空錯誤。我哪裏錯了? 構造:傳遞一個二維數組到一個構造函數
public TheaterSeatSeller(int[][] newSeats)
{
for(int i=0; i<newSeats.length; i++)
{
for(int j=0; j<newSeats[i].length; j++)
{
seats[i][j]=newSeats[i][j];
}
}
}
,然後測試類
public static void main(String[] args){
//initialize the available seats
int[][] emptySeats = {
{10,10,10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10,10,10},
{10,10,10,10,10,10,10,10,10,10},
{10,10,20,20,20,20,20,20,10,10},
{10,10,20,20,20,20,20,20,10,10},
{10,10,20,20,20,20,20,20,10,10},
{20,20,30,30,40,40,30,30,20,20},
{20,30,30,40,50,50,40,30,30,20},
{30,40,50,50,50,50,50,50,40,30}};
TheaterSeatSeller mySeats = new TheaterSeatSeller(emptySeats);
}
什麼是確切的錯誤?信息?電話號碼?謝謝 –
可能重複[什麼是NullPointerException,以及如何解決它?](http://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-doi-i-fix-它) – Keiwan
注意:在Java中沒有2d數組,你正在使用一個數組數組 –