My code:
int worldSize = 64;
private Tile[][] tiles = new Tile[worldSize][worldSize];
public World() {
for (int i = 0; i < tiles.lenght; i++) {
for (int j = 0; i < tiles[0].lenght;j++) {
tiles[i][j] = new Grass(i * 64, j * 64); // Exception!
}
}
}
The exception:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 64
at World.World.<init>(World.java:13)
at Main.Game.<init>(Game.java:27)
at Main.Main.<init>(Main.java:48)
at Main.Main.main(Main.java:153)
Why is this happening, it’s not the first time and i dont know why!? Help?
Edit: Not working with lenght!