title: Null Pointer Exception when trying to retrieve data from JTable in Swing
body: <p>I have a JTable and I wish to loop through the rows and columns of that table to retrieve each value and then add that value to a 2D array (matrix). However I get a NullPointerException when the last value in the table is attempted to be extracted. I have the following code:</p>
  
  <pre><code>DefaultTableModel dtm = (DefaultTableModel) table.getModel();
          double [][] matrix = new double[rows][cols];
          for(int i=0;i&lt;rows;i++){
              for(int j=0;j&lt;cols;j++){
                  matrix[i][j]=Double.parseDouble((String) dtm.getValueAt(i, j));
              }
          }
  </code></pre>
  
  <p>Any help would be greatly appreciated</p>
  
  <pre><code>Error message Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
  at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
  at java.lang.Double.parseDouble(Unknown Source)
  at Inverse.actionPerformed(Inverse.java:102)
  </code></pre>