Answer the question
In order to leave comments, you need to log in
How to write the value of an object of class Scanner to an array?
Good day, I am very ashamed to ask this question, but I cannot figure out on my own what the compiler swears at.
I have an array with 6 elements.
Created an object of the Scanner class in the body of the cycle, which "passes" through all the emails.
Made it wait each iteration for my input with continue.
But why can’t this be done, is it really very logical to write values to an array like this? Can anyone explain what the problem is and how to do it right?
Answer the question
In order to leave comments, you need to log in
I think you meant to write arr[i] = t.nextInt();
This will be the assignment of the next int from the scanner to the corresponding array element.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question