- import java.io.*;
- class InitArray {
- public static void main(String args[]) {
- try {
- int n;
- int a[] = new int[20];
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- System.out.println("Enter the Array Limit:");
- n = Integer.parseInt(in.readLine());
- System.out.println("Enter the Array elements:");
- for (int i = 0; i < n; i++) {
- a[i] = Integer.parseInt(in.readLine());
- }
- System.out.println("Array elements:");
- for (int i = 0; i < n; i++) {
- System.out.println(a[i]);
- }
- } catch (Exception e) {
- System.out.println("An error occurred: " + e.getMessage());
- }
- }
- }