title: Java array - Out of bounds exception on an initialized array
body: <p>I'm getting an out of bounds exception on the "calendarTable[i][j] = str;" line below. I find this funny because I'm initializing it to 15, and I only iterate to 14. I've tried initializing to 20000 and no matter how large of an array I make, it still gets an index out of bounds error.</p>
  
  <pre><code>public static void main(String[] args) {
          Calendar cal = new GregorianCalendar();
          cal.set(2012, 2, 1);
          cal.set(Calendar.DAY_OF_WEEK, 1);
          int dayOfMonth = 1;
          Object[][] calendarTable = new Object[15][15];
          calendarTable[0] = new String[]{"SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"};
          for (int i = 0; i &lt; 14; i++) {
              for (int j = 0; j &lt; 14; j++) {
                  //calendarTable[i][j] = dayOfMonth++;
                  if(i%2 == 0){
                      String str = String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
                      calendarTable[i][j] = str;
                      cal.add(Calendar.DAY_OF_YEAR, 1);
                  }else{
                      calendarTable[i][j] = dayOfMonth;
                  }
                  calendarTable[i * 2 + 1][j] = "TEST";
              }
          }
          for (int i = 0; i &lt; 14; i++) {
              for (int j = 0; j &lt; 14; j++) {
                  System.out.print(calendarTable[i][j]);
              }
              System.out.println("");
          }
      }
  </code></pre>