Figure 15.2 [4][1] [4][2] [4][3] [4][4] [4][5] Braxton Remy Michelle Ingrid [3][1] [3][2] [3][3] [3][4] [3][5] Alec Mariana Mike Haley Maddox [2][1] [2][2] [2][3] [2][4] [2][5] Jessica Brenda David Anthony [1][1] [1][2] [1][3] [1][4] [1][5] Isolde John Greg Maria Heidi The example of the seating chart actually goes a little against another convention. Two-dimensional arrays are frequently shown as a matrix of values, and the first row in the matrix is normally shown at the top of the matrix. This seating chart has intentionally been displayed from the point of view of the instructor. Using two values to indicate a location is very common. A Football ticket indicates something like and an airline boarding pass may say Row K, Seat 34, Row 29, In the world of mathematics, science and business, a matrix of numbers is Seat D. used for many types of calculations. 15.2 Declaring a Static 2D Array Declaring a static two-dimensional array holds few surprises. Everything you have learned about static one-dimensional arrays in the areas of declarations and definitions is identical. You need an array identifier along with a data type for each element of the array. You also need the new operator to define the size of the array and allocate sufficient memory. There is only one small difference you will see in program Java1501.java, shown in figure 15.3, and that is the need to provide two sets of brackets. The first set of brackets dimensions the number of rows and the second set of brackets dimensions the number of columns in the array. In the first 2D array example every array element is accessed individually. This works, and it is manageable for a small array of two rows by three columns.
Figure 15.2 [4][1] [4][2] Braxton [4][3] Remy [4][4] Michelle [4][5] Ingrid [3][1] Alec [3][2] Mariana [3][3] Mike [3][4] Haley [3][5] Maddox [2][1] [2][2] Jessica [2][3] Brenda [2][4] David [2][5] Anthony [1][1] Isolde [1][2] John [1][3] Greg [1][4] Maria [1][5] Heidi The example of the seating chart actually goes a little against another convention. Two-dimensional arrays are frequently shown as a matrix of values, and the first row in the matrix is normally shown at the top of the matrix. This seating chart has intentionally been displayed from the point of view of the instructor. Using two values to indicate a location is very common. A Football ticket indicates something like Row K, Seat 34, and an airline boarding pass may say Row 29, Seat D. In the world of mathematics, science and business, a matrix of numbers is used for many types of calculations. 15.2 Declaring a Static 2D Array Declaring a static two-dimensional array holds few surprises. Everything you have learned about static one-dimensional arrays in the areas of declarations and definitions is identical. You need an array identifier along with a data type for each element of the array. You also need the new operator to define the size of the array and allocate sufficient memory. There is only one small difference you will see in program Java1501.java, shown in figure 15.3, and that is the need to provide two sets of brackets. The first set of brackets dimensions the number of rows and the second set of brackets dimensions the number of columns in the array. In the first 2D array example every array element is accessed individually. This works, and it is manageable for a small array of two rows by three columns.
Text15-Two-DimensionalArray.docx