How can I create a Java multidemensional array when trying to create a map for a game?

I am working on a game to understand more fundamental concepts of Java and I want to create a game map. So I have created my class, fields, constructor and I want to get started with creating a simple map using a multidemensional array.

Here is what I have so far:

public class GridSquare {
    public int x;
    public int y;
    public Character character;
    public boolean isWall;
    public Item item;
    public Shop shop;
    
    public GridSquare(int gridRow, int gridColumn, Character gridCharacter, boolean isWall, Item gridItem, Shop gridShop) {
        this.y = gridRow;
        this.x = gridColumn;
        this.character = gridCharacter;
        this.isWall = isWall;
        this.item = gridItem;
        this.shop = gridShop;
        
    }
}

The idea is that a character can navigate through the map and when navigating they can come across certain things like items, and shops. I am kind of stuck on where I can go from here because I don’t have too much experience using multidemensional arrays but I want to learn. Please feel free to point me to some helpful resources about this if you can.

Answer

It looks like you want to create a 2D grid of squares, where each square is represented by a GridSquare instance. You can create and initialize such an array as follows:

int width = ...;
int height = ...;
GridSquare[][] gridSquares = new GridSquare[width][height];
for(int x = 0; x < width; x++) {
    for(int y = 0; y < height; y++) {
        gridSquares[x][y] = new GridSquare(x, y, ...);
    }
}

You can at any time get a square at any position using:

GridSquare gridSquare = gridSquares[x][y];

I hope that this answers your question.