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
You need to know that Java is not like C.
When you do this:
Rectangle[][] blocks = new Rectangle[25][25];
All the references in the blocks 2D array are null until you call new and give them a reference.
So you'll have to do this:
for(int i = 0; i < 24; i++){
for(int e = 0; e < 24; e++){
blocks[i][e] = new Rectangle(); // I don't know what arguments it takes.
blocks[i][e].setBounds(e * 20, i * 20, 20, 20);
blocks[i][e].setLocation(e*20, i*20);