Two Dimensional Arrays
1. Two Dimensional Arrays
Often data comes naturally in two dimensional form. Web browser screens are two dimensional, as are spreadsheets, printed pages, and images.
For many of these situations you need a two-dimensional array. This is a collection of cells laid out in a 2D grid, like graph paper. Each cell can hold a value (as with a 1D array). However, now two indexes are needed to specify a cell.
If you have ever used a spreadsheet then you have used a 2D grid for holding and manipulating data.
One programming problem in the 2014 Advanced Placement test for computer science required use of a two dimensional array of object references.
Chapter Topics:
- Two-dimensional Arrays
- 2D Array Declaration
- Initializer Lists
- Different Numbers of cells in each row
- 2D Arrays as Arrays of 1D Arrays
- Printing a 2D Array
Question 1:
(Thought question: ) Do you suspect that 2D arrays in Java are objects?
Source: Bradley Kjell, http://programmedlessons.org/Java9/chap67/ch67_01.html
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 License.