HOW TO TAKE INPUT FROM USER USING ARRAY IN JAVA?


INPUT:-


import java.util.Scanner;

public class example{

public static void main(String args[]){

Scanner sc = new Scanner(System.in);

 int arr[]= new int[5];

 int i;

 System.out.println("Enter your elements : ");

 for(i=0;i<5;i++){

 arr[i]=sc.nextInt();

}

System.out.println("Your Elements ");

 for(i=0;i<5;i++){

System.out.println(arr[i]);

}

}

}

OUTPUT:-