Check out example codes for "how to get an array as input in java". It will help you in understanding the concepts better.

Code Example 1

public class TakingInput {

    public static void main(String[] args) {

        Scanner s = new Scanner(;

        System.out.println("enter number of elements");

        int n=s.nextInt();

        int arr[]=new int[n];

        System.out.println("enter elements");

        for(int i=0;i<n;i++){//for reading array


        for(int i: arr){ //for printing array





Learn ReactJs, React Native from