title: Compare two different type of ArrayLists to find common data
body: <p>I have two ArrayLists. Arraylist one stores objects which contains different attributes whose one of them is an integer arraylist. </p>
  
  <p>Arraylist two is an integer arraylist. I want to compare Arraylist two with the integer arraylist that is being stored in arraylist one. To make it easier for you to understand:</p>
  
  <p>ArrayList1 :                            </p>
  
  <ul>
  <li>Attribute 1</li>
  <li>Attribute 2</li>
  <li>Integer Arraylist</li>
  </ul>
  
  <p>ArrayList2/Integer Arraylist </p>
  
  <p>I have been trying for a few hours to do this but was not successful. This is my idea:</p>
  
  <p>I have these two ArrayLists:</p>
  
  <pre><code>ArrayList&lt;LottoTicket&gt; ticketList = new ArrayList&lt;&gt;(); //ArrayList 1
  
  ArrayList&lt;Integer&gt; drawNums = new ArrayList(); //ArrayList 2
  </code></pre>
  
  <p>Now ArrayList 1 stores object LotteryTicket which have an integer ArrayList called 'set' which stores 5 numbers for the lottery.</p>
  
  <p>Here is my idea to compare the 'set' arraylist to the drawNums arraylist:</p>
  
  <pre><code>for(LottoTicket l : ticketList)
  {        
    if(l.getSet().contains(drawNums.get(1)))
    {
       System.out.println("1 number matches");
    } 
    else 
    {
       System.out.println("No matches");
    }
  }
  </code></pre>
  
  <p>But this does not seem to be a good idea! Any help would be greatly appreciated  &amp; I hope this will also help others!</p>
  
  <p>Thanks</p>