How to get an array as input in java?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to get an array as input in java??

5th Oct 2017, 12:03 PM
Suriya Saga
Suriya Saga - avatar
2 Answers
0
I am afraid to say that i am not really sure of what you mean. If you mean that you want to get an array from the Scanner Object, then convert the String into a char array where there are many ways to do so. for example Scanner in = new Scanner(); return in.nextLine().toCharArray(); or instead of returning the output, just do what you need with the char array I hope helps happy coding
5th Oct 2017, 12:13 PM
SomeoneAwesome78
SomeoneAwesome78 - avatar
0
first initialise an array declare an extra variable call it n for array size loop through the size and take input from the array....like a[i]= sc.nextInt(); loop again to get the output
5th Oct 2017, 1:16 PM
Suhail Pappu
Suhail Pappu - avatar