I'm trying to remove duplicates from table. I want to remove only those rows which are both id and data equal. My code failed at fourth line.
int i=jTable1.getSelectedRow();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
jXDatePicker1.setFormats(dateFormat);
String date = dateFormat.format(jXDatePicker1.getDate()).toString();
String c1=jTable1.getValueAt(i, 0).toString();
String c2=jTable1.getValueAt(i, 1).toString();
String c3=jTable1.getValueAt(i, 2).toString();
String c4=jTable1.getValueAt(i, 3).toString();
String c5=price.getText().toString();
String c6=jTextField1.getText().toString();
String c7=date;
model.addRow(new Object[]{c1, c2, c3, c4, c5, c6, c7});
jTable2.setModel(model);
ArrayList<String> list = new ArrayList();
int rows = jTable2.getRowCount();
for (int m=0; m<rows; m++){
String ids = jTable2.getValueAt(m, 0).toString();
String data = jTable2.getValueAt(m, 6).toString();
if (list.contains(ids)&&list.contains(data)) {
JOptionPane.showMessageDialog(null, "Record exist");
model.removeRow(jTable2.getRowCount()-1);
}
else{
list.add(ids);
list.add(data);
}
}