Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

To make 2-dimensional array a bit of life and bringing them from the abstract to

ID: 3556861 • Letter: T

Question

To make 2-dimensional array a bit of life and bringing them from the abstract to the concrete realms. Please write a few lines of code defining a 2-dimensional array and how it could be used in a given application to solve a specific problem. Note: Please make sure you explain what your code is doing and what problem the 2-dimensional array solves.

Is it possible to substitute a 2-dimensional array with a 1-dimensional array?
How would this substitution work? How does the single index replace the two indexes used in a 2-dimensional array?
Please use a code snippet to make your point.

Explanation / Answer

Two-dimensional arrays are objects. A variable such as gradeTable is a reference to a 2D array object. The declaration

says that array is expected to hold a reference to a 2D array of int. Without any further initialization, it starts out holding null. The declaration

says that array can hold a reference to a 2D array of int, creates an array object of 3 rows and 5 columns, and puts the reference in array. All the cells of the array are initialized to zero. The declaration

does exactly the same thing as the previous declaration (and would not ordinarily be used.) The declaration

creates an array of the same dimensions (same number of rows and columns) as the previous array and initializes the cells to specific values.

i

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote