title: Sum a Column in a jTable?
body: <p>I am having a problem trying to get values from a column within a jTable and sum them up. This is the code I have so far:    </p>
  
  <pre><code>public void saveTable(){
      for(int i = 0; i &lt; jTable2.getRowCount(); i++){
          int total = 0;
          int Amount = (int) jTable2.getValueAt(i, 5);
          total = Amount+total;
          System.out.println(total);
      }
  }
  </code></pre>
  
  <p>However I keep getting ClassCastException Errors specifically:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException:      java.lang.String cannot be cast to java.lang.Integer
  at my.rcsv1.accounting.DraftInvoice.saveTable(DraftInvoice.java:851)
  </code></pre>
  
  <p>Which is referring to the line of code:</p>
  
  <pre><code>int Amount = (int) jTable2.getValueAt(i, 5);
  </code></pre>
  
  <p>What do I need to do in order to get this to work?</p>
  
  <p>Thank you!    </p>