In your case, the 1D array (list) looks the same on the screen like the 2D array (grid). This is because you have given the objects in the list screen positions that arrange them in a grid. With a 2D array the data internally looks more like on the screen, because a grid has a column and a row number for each data (cell).
Explanation
But internally they are different: the data is stored differently.
-
For a list you need only one value to retrieve the entry of one line/cell (line number 4: list[3] (counting starts with 0); 3 is the index for the array)
-
For a 2D array you need 2 numbers to get to a cell, x and y position of the cell in the array (not on screen) like grid[3] [5] gives you the data in column 4 and row 6. Think of a chess board where we also say e2 (it’s like saying 5,2) or think of an Excel sheet (calculation program by Microsoft)
Example for a grid
Let’s say your program holds data for 10 students, and each has name, surname, address, age.
In a list that would be difficult.
In a grid, you would have one line per student and in the columns the data for her like name, surname, address, age. To retrieve the age of student #2 you’d check the cell 3,3 (counting starts with 0).
Each data is retrieved by passing it two indexes (think of a chess board with rows and columns). Each data is a String or a number or a color.
A grid looks something like this:
-----------
| 0| 1|
-----------
| 2| 3|
-----------
| 0| 1|
-----------
| 2| 3|
-----------
Chrisir