ArrayIndexOutOfBounds WTF?

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!

This isn’t valid code. Arrays don’t have a size() function, they have a length variable.

If that complies I’m guessing you have a List tiles variable hiding your Tile[][], as that would be tiles.length not size()

EDIT: Half-ninja’d

Yea my mistake copying it it’s lenght there! Not working!

for (int i = 0; i < tiles.length; i++) {
-    for (int j = 0; i < tiles[0].length;j++) {
+    for (int j = 0; j < tiles[0].length;j++) {
        tiles[i][j] = new Grass(i * 64, j * 64);
    }
}

Ok thanks! xD