+ 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]); } } }
3 Respuestas
+ 1
Look at the code. Hope it helps you 😉
https://code.sololearn.com/csI8MSgsQSSN/?ref=app
+ 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
+ 1
Thank you so much