Skip to content
Advertisement

Creating a Java increasing alphabet grid with a 5×5 array

The grid I need to recreate looks like this

JavaScript

The grid I have now looks like this

JavaScript

My code for creating the grid

JavaScript

I have already declared these variables in the public class, not my main method. How would I achieve this? I tried changing the int’s in the middle section of my map to char like my top and bottom section but it just cuts the middle portion of the map out.


public static int numRows = 5;


public static int numCols = 5;


public static String[][] maze = new String[numRows][numCols];

Advertisement

Answer

A simple way to complete your code is the use of chars where you already have your output.

JavaScript

Now let’s test it:

JavaScript

Looks good. 🙂

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement