+ 1
How to allow the user to enter multiple inputs in java?
2 ответов
+ 5
You can also do this:
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
String c = scan.nextLine();
...
or
while(scan.hasNext()){
//fill an array or list with your input if you don't want to write int a = ..., int b = ...
}
+ 1
Scanner scan = new Scanner(System.in);
String text = "";
System.out.println("Enter some text:");
// So long the use not write 'quit' the loop will keep run
while(!text.equals("quit")){
text = scan.nextLine();
}