Package test17;
Import java.util.scanner;
Class test 17 {
Public static void main(String[] args) {
System.out.println ("Please enter a number:");
Scanner input = new scanner (system. in);
string str = input . nextline();
string x[]= str . split(" "); Use split to divide by spaces and assign values to array x;
for(int I = 0; I<x. Length; i++)
system . out . print(x[I]+" ");
}
}
Another way is to assign values one by one by using the for loop, but the above method is relatively simple, and you can enter as many numbers as you like.
I hope it helps you!