V
V
Vladimir Stepanov2020-12-16 19:50:57
Java
Vladimir Stepanov, 2020-12-16 19:50:57

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.
5fda3a9d37d66013058022.png
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

1 answer(s)
D
Denis Zagaevsky, 2020-12-16
@Simpelax

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 question

Ask a Question

731 491 924 answers to any question