Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

How can I store user inputs in an array of integers?

  public static void main(String[] args) {
      
        Scanner input = new Scanner(System.in);
      
        int[] xr = new int[5];

        for (int i = 0; i < xr.length; i++) {
            xr[i] = input.nextInt();
        }

        System.out.println(Arrays.toString(xr));
    }
 
PREVIOUS NEXT
Tagged: #How #I #store #user #inputs #array
ADD COMMENT
Topic
Name
8+3 =