+ 1

I want to inter two values on zarray variable Then they want to show up

package Mohit; import java.util.*; import java.util.Scanner; public class c { public static void main(String[] args) { int [] zarray = new int[2]; for (int i=0; i<2;i++) { Scanner zarray = new Scanner(System.in); System.out.println(zarray[i]); } } }

1st Jun 2019, 2:52 PM
Mohit Ravindra Jadhav
Mohit Ravindra Jadhav - avatar
3 Respuestas
+ 1
Look at the code. Hope it helps you 😉 https://code.sololearn.com/csI8MSgsQSSN/?ref=app
1st Jun 2019, 3:03 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
I'm guessing you want to take multiple inputs from the user First of all, if you want to use Scanner, you shouldn't import everything, then Scanner, just: import java.util.*; To take multiple inputs, first you need to know, that it doesn't work like arrays: Scanner zarray = new Scanner(System.in); to take multiple inputs, usr zarray.nextInt() or zarray.nextLine() nextInt returns the next integer, and nextLine returns the next line
1st Jun 2019, 3:10 PM
Airree
Airree - avatar
+ 1
Thank you so much
1st Jun 2019, 4:48 PM
Mohit Ravindra Jadhav
Mohit Ravindra Jadhav - avatar