title: intersection of two list of different object in java
body: <p>I have two Pojo Classes on with different field with unique ID.</p>
  
  <p>I want to perform intersection of two <code>List&lt;A&gt;</code> and <code>List&lt;B&gt;</code> .</p>
  
  <p>What is best way to do. One is i can simply iterate twice and but then the complexity is too high n2.</p>
  
  <p>is any better way to do that ? Can i Do it with Comparator?</p>
  
  <pre><code>Class A {
  Id, Name ,DOB}
  
  Class B{
  id, aid ,location }
  </code></pre>
  
  <p>I have list of A , and List of B </p>
  
  <p>now want to get list of A with location in B</p>