title: Getting Array Out Of Bounds Error in Java
body: <p>I am new to Java and i wrote a simple program that calculates the sum of multiples of 3 below 10.
  I am not sure why i am getting Array Out Of Bounds Exception</p>
  
  <pre><code>int a[] = {},j = 0,sum = 0;
          for(int i=1;i&lt;=10;i++)
          {
              if ((i % 3) == 0)
              {
              a[j] = i; // Here, i am getting the exception
              j++;
              }
          }
          for(int i1=0;i1&lt;j;i1++)
          {
              sum = sum + a[i1];
          }
          System.out.println(sum);
       }
  </code></pre>