+ 1

How to allow the user to enter multiple inputs in java?

11th May 2019, 4:47 PM
benny deuel
benny deuel - avatar
2 Respostas
+ 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 = ... }
12th May 2019, 5:17 PM
Denise Roßberg
Denise Roßberg - avatar
+ 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(); }
11th May 2019, 5:14 PM
JavaBobbo
JavaBobbo - avatar