bagaimana cara mendapatkan jumlah barisan barisan di kolom di java

jTable1.setColumnSelectionAllowed(true);
jTable1.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);



public void calculate() {
    calculate(jTable1, jTable1.getSelectedColumn(), jTable1.getSelectedRows());
}

public void calculate(JTable table, int column, int[] rows) {
    int result = 0;
    for (int row : rows) {
        result += Integer.valueOf(table.getValueAt(row, column).toString());
    }
    ((DefaultTableModel) table.getModel()).addRow(new Object[]{result});
}
Energetic Eel