That is because you declare your data array without actually initializing it:Object[][] data;Should become:Object[][] data = new Object[x][y];Where x and y are the size of your multi-dimensional array.