I have inputs such as "1 2 3" being inputted into my program.
I am using Scanner to look for the numbers. I would like to put these numbers into an array, but how would I initialize the array size if the inputs vary in size? For example, what if the input has more than 3 numbers?
Here is the code I am working with:
Scanner scan = new Scanner(System.in);
int  array = new int ;
for (int i = 0; i < array.length; i++)
array[i] = scan.nextInt();
for (int z = 0; z< array.length; z++)
System.out.print(array[z] + " ");