How to get an array as input in java??

5th Oct 2017, 12:03 PM
Suriya Saga
Suriya Saga - avatar
2 Answers
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 - avatar
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