title: Get all duplicate objects from list
body: <p>I want to create a new list with only the transactions from the input list that meet the following requirement: The name and code should be on the input list multiple times. (See example.) The items and ID are not relevant. </p>
  
  <p>Input list</p>
  
  <pre><code>List&lt;Transactions&gt; transactionsList;
  +----+------+----+-------+
  | id | name |code|  item |
  +----+------+----+-------+
  | 1  | john | A1 | shoes |
  | 2  | john | A1 | shirt |
  | 3  | anon | A2 | shoes |
  | 4  | anon | A2 | shoes |
  | 5  |nymous| A3 | tie   |
  +----+------+----+-------+
  </code></pre>
  
  <p>Expected result</p>
  
  <pre><code>+----+------+----+-------+
  | id | name |code|  item |
  +----+------+----+-------+
  | 1  | john | A1 | shoes |
  | 2  | john | A1 | shirt |
  | 3  | anon | A2 | shoes |
  | 4  | anon | A2 | shoes |
  +----+------+----+-------+
  </code></pre>
  
  <p>I've tried using this code </p>
  
  <pre><code>List&lt;Transactions&gt; filteredTransactionList = new ArrayList&lt;&gt;();
  
  for(Transactions transaction : transactionList){
      if (transactionList.stream().anyMatch(f -&gt; 
          f.getName().equals(transaction .getName())) &amp;&amp; 
          transactionList.stream().anyMatch(f -&gt; f.getCode().equals(transaction .getCode())) ) {
                      filteredTransactionList.add(transaction );
      }
  }
  </code></pre>
  
  <p>But it seems like this code won't work since the if condition will always be true when it found itself in the list</p>
  
  <p>Is there any way to achieve it without using .stream if possible? 
  Someone said that I can achieve it using map but I can't find the way to do so. It's fine using anything if there is no other option.</p>
  
  <p>I'd have to keep the for loop for my other if() function.</p>