title: How to extract numbers from Two-Dimensional Array of Objects in Java
body: <p>I have a two-dimensional object array which becomes filled with student names and grades. Each student has its own row and the first column contains the student names and then next 4 columns contain test grades. I need to find the average of each student's tests but I don't know how to average each row's double values. I also need to find the average of all the tests in the data base. Can someone show me how to do this? </p>
  
  <pre><code>public class StudentGrades extends javax.swing.JFrame {
      Object[][] database = new Object[14][5];
      int studentCount = 0;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                               
      //declare variables
      double grade1 = Double.parseDouble(test1.getText());
      double grade2 = Double.parseDouble(test2.getText());
      double grade3 = Double.parseDouble(test3.getText());
      double grade4 = Double.parseDouble(test4.getText());
      String name = firstInput.getText() + " " + lastInput.getText() + ":";
  
      if (grade1 &gt;= 0 &amp; grade1 &lt;= 100 &amp; grade2 &gt;= 0 &amp; grade2 &lt;= 100 &amp; grade3   &gt;= 0 &amp; grade3 &lt;= 100 &amp; grade4 &gt;= 0 &amp; grade4 &lt;= 100){
  
          //add data
          database[studentCount][0] = name;
          database[studentCount][1] = grade1; 
          database[studentCount][2] = grade2;
          database[studentCount][3] = grade3;
          database[studentCount][4] = grade4;
  
          //add to student count
          studentCount = studentCount + 1;
  
          //limit number of students
          if (studentCount == 15){
              addButton.setEnabled(false);
          }
      }  
      else {
          errorLabel.setText("Please Enter Valid Data.");
      }
  </code></pre>