Tenho quatro colunas onde três multiplicam e a quarta coluna retorna a multiplicação das três colunas trazendo o resultado.. O problema é que em algumas colunas é dados valores para as outras três colunas fazendo com que o meu código retorne 0 para elas. Preciso que não retorne 0 para as colunas que não estão preenchida. É possível?
Segue o código:
for (int row = 0; row < jTable1.getRowCount(); row++) { int severidade = 0; int ocorrencia = 0; int deteccao = 0; if (jTable1.getValueAt(row, 7) != null && jTable1.getValueAt(row, 7).toString() != "") { severidade = Integer.valueOf(jTable1.getValueAt(row, 7).toString()); } if (jTable1.getValueAt(row, 12) != null && jTable1.getValueAt(row, 12).toString() != "") { ocorrencia = Integer.valueOf(jTable1.getValueAt(row, 12).toString()); } if (jTable1.getValueAt(row, 14) != null && jTable1.getValueAt(row, 14).toString() != "") { deteccao = Integer.valueOf(jTable1.getValueAt(row, 14).toString()); } jTable1.setValueAt(severidade * ocorrencia * deteccao, row, 15); }