I\'m trying to make a 2D tile game and when making the arrays holding the tiles I get a NullPointerException, here is some of the code. Sorry if this is poorly formatted, first
When you create an object array, you are creating an array of references, but you are not assigning the references. You must do this first before trying to use them. Think of it as being similar to creating an egg carton. You can't use any eggs until you first fill the carton with eggs. So for instance your blocks array, you first need to assign Rectangle objects to each item in the array before you can call methods on them. This is usually done in a for loop. e.g.,
for(int i = 0; i < 24; i++){
for(int e = 0; e < 24; e++){
blocks[i][e] = new Rectangle(....); //...
blocks[i][e].setBounds(e * 20, i * 20, 20, 20);
blocks[i][e].setLocation(e*20, i*20);