i am just trying to populate this array with some information. i have no idea why, but i am getting:

java.lang.ArrayIndexOutOfBoundsException: 0

im probably just stupid 0_o... but, here is my code:

private boolean populated = false;

private int blockList[][] = {};

public void update(){

    if(populated == false){
        int a = 0;
        for(int i = 0; i < 200; i++){
            for(int j = 0; j < 50; j++){
                blockList[a][0] = i;
                blockList[a][1] = j;
                blockList[a][2] = 1;
                a++;
            }
        }
        populated = true;
    }

}

all input, even if not direct help, is very much appreciated.

java.lang.ArrayIndexOutOfBoundsException: 0

That error says the array is defined with no elements. There is not an element at index 0;

You need to define the array large enough to hold all the data you want to put into it.

A [][] array is an array of arrrays. First you need to initialise the first/outer array, then you need to initialise the inner/second arrays, although you can do both at once provided all the inner arrays are the same length egint[][] blocklist = new int[6][3]
Your code just initialised the outer array to have no elements - {} - in which case there are no inner arrays at all. If that array is zero length, then any index will be out opf range.

thatnk you! fixed it! i understand now, too. does everything like that have to be initialised before i can use it?

This question has already been answered. Start a new discussion instead.