0
Discuss the arrays in java
How to get the user value from a scanner if there were arrays in it, would show the answer to the arrays number
5 Answers
0
Can you clarify your question? With an example maybe?
0
I use an interpreter because I do not know English. Perhaps I can not understand my meaning
0
scanner new scanner system .in ..
scanner.nextLine
arrAys(maral . ali)
if value = arrays
Answer number arrays
else
not found
0
ۧ Did you understand?
0
Scanner does not have a method to read an array.
See: https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html
It does have a method nextLine() which reads the line as a String.
You can split the string into smaller parts (or tokens), for instance by spaces (" ").
You can create Integers of the values of these Strings (assuming the String contains digits)
Example: https://code.sololearn.com/c7vjGPArX3K3
Alternatively, you can use Scanner's nextInt() method to read all the ints and add them to an array
Example:https://code.sololearn.com/cYJCmOrZw5bn
To see if the array you have read is the same as another array, simply loop over both arrays and compare each value.
Does this answer your question?