How can I input multiple times in one line?
public class Awit {
static void numbers(){
Scanner user = new Scanner(System.in);
int arraylist[] = new int [5];
System.out.println("Enter five integers:");
System.out.print("");
for(int i = 0; i<=4; i++){
arraylist[i] = user.nextInt();
}
public static void main (String []args){
numbers();
}
}
Output:
Enter five integers:
1
2
3
4
5
I want the output to be like this
1 2 3 4 5