title: I'm unable to store values in array as it is showing error?
body: <p>I have to take the size of the array from user input and store it
  and also I tried to store values in array ac to size but when I run the program, for loop executes once after its showing an error of boundary exception</p>
  <pre><code> import java.util.Scanner;     
  
   public class Odd {
      int size;
      int a[] = new int[size];
  
      public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          System.out.println(&quot;Enter Size of array&quot;);
          size = sc.nextInt();
          for (int i = 0; i &lt; size; i++) {
              System.out.println(&quot;enter &quot; + i + &quot;th element&quot;);
              a[i] = sc.nextInt();
          }
          System.out.println(&quot;your array is&quot;);
          for (int i = 0; i &lt; size; i++) {
              System.out.print(a[i] + &quot; &quot;);
          }
      }
  }
  </code></pre>