Scanning for input without storing the values in a variable

后端 未结 2 1586
感情败类
感情败类 2021-01-28 12:01

I\'m declaring a 2d Array with 100 rows and columns. Im trying to get the user to dictate the numbers that go into the array. Im supposed to store the values without storing the

2条回答
  •  忘了有多久
    2021-01-28 12:31

    You'll need to use nested for loops for a 2-d array (one for rows and one for columns):

    for (int i = 0; i < nums.length; ++i)
         for (int j = 0; j < nums[i].length; ++j)
    {
    
        nums[i][j] = scan.nextInt();
    
    }
    

提交回复
热议问题