0

How can I make multiple scanners?

22nd Jan 2020, 12:34 AM
Michael Trungold
Michael Trungold - avatar
6 Respuestas
+ 1
int a = sc.nextInt() ; int b = sc. nextInt() ; The input must be 25 67 Then a equals 25 and b equals 67
25th Jan 2020, 4:15 AM
Julio Codesal
Julio Codesal - avatar
+ 4
You need not do that, just declare a single scanner class and you can use it to take as many inputs for different variables of different types. For eg- Scanner sc = new Scanner (System.in); int a = sc.nextInt(); float b = sc.nextFloat(); double c = sc.nextDouble(); String str = sc.nextLine(); ...And so on for other types.
22nd Jan 2020, 2:00 AM
Avinesh
Avinesh - avatar
+ 2
You can use loops too
23rd Jan 2020, 4:01 PM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
25th Jan 2020, 4:18 AM
Julio Codesal
Julio Codesal - avatar
0
Maybe your problem is that here in the app the input for the multiple scanner of your code must be all in one time separate be enter
22nd Jan 2020, 5:55 AM
Julio Codesal
Julio Codesal - avatar
0
What about if I need multiple inputs of one type, like two separate int variables
25th Jan 2020, 4:03 AM
Michael Trungold
Michael Trungold - avatar