Accessing and updating the values of a 2D array

In Java, accessing and updating values in a 2D array is done using the row and column indices. The general format is:

- **Accessing a value**: array[row][column]
- **Updating a value**: array[row][column] = newValue;

image

Popcorn Hack 1 (Part 2)

  • Update the values of the array, you made in part 1 to the group members in another group
// Boiler Plate Code
String[][] myArray = new String[2][2];

myArray[0][0] = "Joe";
myArray[0][1] = "Moe";
myArray[1][0] = "Billy";
myArray[1][1] = "Willy";

System.out.print("My new array of members but idk any groups:");
System.out.println();
for(int i = 0; i < myArray.length; i++) {
    for (int j = 0; j < myArray[i].length; j++) {
        System.out.print(myArray[i][j] + " ");
    }
    System.out.println();
}
My new array of members but idk any groups:
Joe Moe 
Billy Willy