title: How to check for duplicate records in excel using POI?
body: <p>below is the code for reading the excel file using poi: which is working fine</p>
  
  <pre><code>public class ReadExcelDemo { 
      public static void main(String[] args)  { 
   try {           
       FileInputStream file = new FileInputStream(new File("demo.xlsx"));  
       List sheetData = new ArrayList();
  
      XSSFWorkbook workbook = new XSSFWorkbook(file); 
  
      XSSFSheet sheet = workbook.getSheetAt(0);
    ArrayList&lt;Form&gt; vipList = new ArrayList&lt;Form&gt;();
      Iterator&lt;Row&gt; rowIterator = sheet.iterator();   
      while (rowIterator.hasNext()) {            
          Row row = rowIterator.next();
  
          Iterator&lt;Cell&gt; cellIterator = row.cellIterator();   
          List data = new ArrayList();
  
          while (cellIterator.hasNext())  { 
  
              Cell cell = cellIterator.next();    
  
              switch (cell.getCellType())                     {        
                  case Cell.CELL_TYPE_NUMERIC:  System.out.print(cell.getNumericCellValue() + "\t"); 
              break;                       
                  case Cell.CELL_TYPE_STRING: System.out.print(cell.getStringCellValue() + "\t");  
              break;     
              }           
          }
  
      }  
  
  
      }
  </code></pre>
  
  <p>Now if excel contains duplicate records I should be able to print a simple error message. How do I do that?</p>
  
  <p>Example:</p>
  
  <pre><code>ID    Firstname     Lastname     Address
    1     Ron           wills      Paris
    1     Ron           wills      London
  </code></pre>
  
  <p>Now i want to check the duplicates only for the 3 columns: ID,Firstname and Lastname together. If these columns together contain same data as shown in the above example then it needs to be considered duplicate.</p>
  
  <p>I have a pojo class Form consisting of the id,firstname and lastname with getters</p>
  
  <p>and setters. Each record read is written to the pojo class using the setter methods. Then I am getting the values using getters and adding them to the arraylist object. Now the list object contains all the records. How do I compare them? </p>