Java List Error (Out Of Bounds)
<p>I am attempting to make an infinite world 2d game</p>

<p>source for the class is here:</p>

<pre><code>package com.blazingkin.world;
import java.util.LinkedList;
import java.util.List;

import com.blazingkin.atrox.AtroxAdventrum;

public class World {

    public World(AtroxAdventrum aa){
        chunks = new LinkedList&lt;List&lt;Chunk&gt;&gt;();
    }

    public void setBlock(int x, int y, int newBlock){

    }

    public void setMetadata(int x, int y, int newMeta){

    }
    public int getBlock(int x, int y){
        try{
            Chunk c = chunks.get(x/64 - x%64).get(y/64 - y%64);
            return c.chunk[x%64][y%64];
        }
        catch(Exception e){
            try{
            Chunk c = new Chunk(y, x/64 - x%64, y/64 - y%64);
            chunks.get(x/64 - x%64).add(y/64 - y%64 - 1, c);
            return c.chunk[x%64][y%64]; 
        }catch(Exception e1){
            Chunk c = new Chunk(y, x/64 - x%64, y/64 - y%64);
            List&lt;Chunk&gt; newlist = new LinkedList&lt;Chunk&gt;();
            System.out.println(""+x+", "+y);
            for (int i = 0; i&lt;y/64 - y%64; i++){
                newlist.add(i, new Chunk(y - (y/64 - y%64 - i), x/64 - x%64, y/64 - y%64 - (y/64 - y%64 - i)));
            }
            newlist.add(y/64 - y%64 - 1, c);
            for (int i = 0; i&lt;x/64 - x%64; i++){
                newlist.add(i, new Chunk(x - (x/64 - x%64 - i), x/64 - x%64, x/64 - x%64 - (x/64 - x%64 - i)));
            }
            chunks.add(x/64 - 1 - x%64, null);

            return 0;
        }
        }




    }
    public int getMetadata(int x, int y){
        return 1;
    }



    public List&lt;List&lt;Chunk&gt;&gt; chunks;

}
</code></pre>

<p>However, when i attempt to run this code i get the following error:</p>

<p>Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 23, Size: 0
    at java.util.LinkedList.entry(Unknown Source)
    at java.util.LinkedList.add(Unknown Source)
    at com.blazingkin.world.World.getBlock(World.java:41)
    at com.blazingkin.render.ScreenOutput.render(ScreenOutput.java:30)
    at com.blazingkin.atrox.AtroxAdventrum.draw(AtroxAdventrum.java:34)
    at com.blazingkin.atrox.Core.gameLoop(Core.java:60)
    at com.blazingkin.atrox.Core.run(Core.java:27)
    at com.blazingkin.atrox.AtroxAdventrum.main(AtroxAdventrum.java:14)</p>

<p>Any suggestions as to how i could fix this?</p>
