Q:

Java Make declare and initialize 2d array of my object

I am working on making a program that makes a grid of a random size >1 and then randomly puts walls inside the maze. The program is then supposed to find a route from the starting point to the goal. I am using a breadth search.
my problem is that I could not find a way to store coordinates so I made my own class Coord that has an x and y value. for part of my algorithm I need to make a 2d array of type Coord
I cannot seem to get it to work, every time I try to run the program I get a ArrayIndexOutOfBoundsException. I don't know why or how to allocate this array and It is needed for my algorithm.
Here is the code that I am trying to run:
Coord[][] test2dArray = new Coord[3][3];
test2dArray = Coord.make2dArray(3, 3);

This is calling:
public class Coord {
int x;
int y;

public static Coord[][] make2dArray(int sizex, int sizey){
    Coord[][] array= new Coord[sizex][sizey];
    for(int x=0; x<sizex; x++){
        for(int y=0; x<sizey; y++){
            array[x][y] = new Coord(0,0);
        }
    }
    return array;
}

So far I do have a 1d array working with this code:
Coord[] testArray = Coord.makeArray(4);

Which is calling:
public static Coord[] makeArray(int size){
    Coord[] array= new Coord[size];
    for(int i=0;i<size;i++){
        array[i]= new Coord(0,0);
    }
    return array;

}

If you could help me and explain what is going on that would be great! Thanks so much for all your help :)

A:

The line
for(int y=0; x<sizey; y++)

should be
for(int y=0; y<sizey; y++)

The condition y<sizey is needed to stop y being too large and causing an ArrayIndexOutOfBoundsException. Your typo means that y is not stopped.

