Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class Array {
- public static void main(String[] args) throws IOException
- {
- BufferedReader ch=new BufferedReader(new InputStreamReader(System.in));
- System.out.println("Hello Worldn");
- System.out.println ("nEnter the number of elements:");
- int n=Integer.parseInt(ch.readLine());
- int a[]=new int[n];
- for (int i=1;i<=n;i++)
- {
- a[i]=Integer.parseInt(ch.readLine());
- }
- System.out.println ("nThe elements are as follows:n");
- for(int i=1;i<=n;i++)
- {
- System.out.println (a[i]+"t");
- }
- }
- }
- Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
- at Array.main(Array.java:26)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement