title: sum of columns in a 2 dimensional array
body: <pre><code>static double [][] initialArray = {{7.432, 8.541, 23.398, 3.981}, {721.859, 6.9211, 29.7505, 53.6483}, {87.901, 455.72, 91.567, 57.988}};
  
  public double[] columnSum(double [][] array){
      int index = 0;
      double temp[] = new double[array[index].length];
  
      for (int i = 0; i &lt; array[i].length; i++){
          double sum = 0;
  
          for (int j = 0; j &lt; array.length; j++){
              sum += array[j][i];
  
          }
          temp[index] = sum;
          System.out.println("Index is: " + index + " Sum is: "+sum);
          index++;
  
      }
  
      return temp;
  }
  
  
  public static void main(String[] args) {
      arrayq test = new arrayq();
      test.columnSum(initialArray);
  
  }
  </code></pre>
  
  <p>I want to get the sum of all the columns, but I keep getting an outofbounds exception. This is the output I get: </p>
  
  <pre><code>Index is: 0 Sum is: 817.192
  Index is: 1 Sum is: 471.18210000000005
  Index is: 2 Sum is: 144.7155
  Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
  at NewExam.arrayq.columnSum(arrayq.java:11)
  </code></pre>