Aadi Aadi - 11 months ago 60
Java Question

How to take input in java without spaces?

How can i take input for an integer array in a single line without spaces. Number can be only from 0-9 so every thing is single digit.




a[0]=1 a[1]=2 a[2]=3 a[3]=4 a[4]=5 a[5]=6

Please help me with this issue.

Answer Source

Take in in as a String and use split() -method like this:


will produce an array of strings

array ["1", "2", "3"]