0

How do I go about declaring variables in a 2D Java array that has 5 first names and 5 last names? This is what I think is correct but I am unsure:

String[][] flNames = new String[5][5];

Also how do I go about declaring variables for a 2D array that has 5 last names and 10 assignment names that can be either essays or labs, not both. This is what I have :

String[][] namesAssign = new String[5][10];
shmosel
  • 49,289
  • 6
  • 73
  • 138
Jon Beach
  • 13
  • 2

1 Answers1

0

Yes, here's an example of adding information to the array:

String[][] flNames = new String[5][5];
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            flNames[i][j] = "Test" + i + j;
        }
    }
    System.out.println(flNames[4][4]);
MuffsEZ
  • 21
  • 4
  • Please explain your solution instead of just dumping code. Help people to learn and understand, not just copy & paste. – Robert Jun 27 '18 at 20:56