title: Iterator to return list
body: <p>I am trying to implement this with the help of enhanced for loop, but my question is if I use the iterator for the example below how do I make sure that my return type is picking up the corresponding value of "XYZ"?</p>
  
  <pre><code>List&lt;Apples&gt; a1 = new List&lt;Apples&gt;();
  if(a1.iterator().next().equals("XYZ")
  {
     return a1.iterator().next().getFruits();
  }
  </code></pre>