1int n;
2Scanner sc=new Scanner(System.in);
3System.out.print("Enter the number of elements you want to store: ");
4//reading the number of elements from the that we want to enter
5n=sc.nextInt();
6//creates an array in the memory of length 10
7int[] array = new int[10];
8System.out.println("Enter the elements of the array: ");
9for(int i=0; i<n; i++)
10{
11//reading array elements from the user
12array[i]=sc.nextInt();
13}
14System.out.println("Array elements are: ");
15// accessing array elements using the for loop
16for (int i=0; i<n; i++)
17{
18System.out.println(array[i]);
19}
20}
21}