title: ArrayList check for duplicates
body: <p>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. There are two equal ids but dates are different. It's the only case when I get error. I tried adding diffrent rows and it worked just fine.             </p>
  
  <pre><code>        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&lt;String&gt; list = new ArrayList();
          int rows = jTable2.getRowCount();
          for (int m=0; m&lt;rows; m++){
              String ids = jTable2.getValueAt(m, 0).toString();
              String data = jTable2.getValueAt(m, 6).toString();
              if (list.contains(ids)&amp;&amp;list.contains(data)) {
                  JOptionPane.showMessageDialog(null, "Record exist");
                  model.removeRow(jTable2.getRowCount()-1);
              }
              else{
                  list.add(ids);
                  list.add(data);
              }
          } 
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/MJLdJ.png" alt="enter image description here"></p>