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

21st Jul 2017, 10:27 AM
M .Q
5 ответов
0
Can you clarify your question? With an example maybe?
22nd Jul 2017, 7:09 PM
marit vandijk
0
I use an interpreter because I do not know English. Perhaps I can not understand my meaning
23rd Jul 2017, 4:41 AM
M .Q
0
scanner new scanner system .in .. scanner.nextLine arrAys(maral . ali) if value = arrays Answer number arrays else not found
23rd Jul 2017, 4:45 AM
M .Q
0
ا Did you understand?
23rd Jul 2017, 4:47 AM
M .Q
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?
23rd Jul 2017, 5:44 PM
marit vandijk