I have an array:
[ 0 0
1 0
2 0
3 0
4 0
5 0 ]
How do I specify where the user input (using scanner) will go to in the array? I would like to add an integer to each position of the second column.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For an
array of array, to get the number of rows, you use the length of your array.For e.g, for this array: –
arr.lengthgives you number of rows in the array, i.e.3. So, run a loop from0 to arr.length, to access each row.Now, to access the
2nd columnof each row, you can doarr[i][1]in your loop: –Also, to get user input to fill your
2nd columnfor each row, you have to read input for each row. So, you can guess where you need to read the user input – Inouter loop, or ininner loop?