title: How to compare each record with all other records in a same List Java?
body: <p>I have a list :</p>
  
  <pre><code>List&lt;BookDTO&gt; bookList = libraryDTO.getBooks();
  
  int bookCounter = 0;
  for (BookDTO bookdto : bookList)
  {
         if ((!errors.isEmpty() &amp;&amp; !errors.containsKey("book[" + bookCounter + "].bookRefNo") || errors.isEmpty()) &amp;&amp;
             // do comparison for each record with other records in same list ) {
  
             errors.put("book[" + bookCounter + "].bookRefNo", messageSource.getMessage("bookRefNo.cannot.be.same", null, null));
          }
  
      bookCounter++;
      }
  </code></pre>
  
  <p>Now, I dont know how to do the comparison checking.. basically if there are matching records(records that having same value), I should get the key.</p>