Question: In java, if I have a matrix (well, two arrays) with columns and rows of equal length such as below: 0 0 0 0 0

In java, if I have a matrix (well, two arrays) with columns and rows of equal length such as below:

0 0 0

0 0 0

0 0 0

How do I initialize the value of the array to equal the array number in which they are stored? I think I should use .length or .length - 1 but am a bit confused.

For example:

0 1 2

0 1 2

0 1 2

Is there a way I could do this using a for loop? I don't want to just hard code the values in.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!