title: Foreach loop in java for a custom object list
body: <p>I have an ArrayList for type Room (my custom object) Defined as below</p>
  
  <pre><code>ArrayList&lt;Room&gt; rooms = new ArrayList&lt;Room&gt;();
  </code></pre>
  
  <p>After then adding a series of objects to the ArrayList I want to go through them all and check various things. I am not a keen user of java but I know in many other programming languages a foreach loop would be the most simple way of doing this.</p>
  
  <p>After a bit of research I found the following link which suggests the code below.
  <a href="https://stackoverflow.com/questions/85190/how-does-the-java-for-each-loop-work">How does the Java &#39;for each&#39; loop work?</a></p>
  
  <pre><code>for(Iterator&lt;String&gt; i = someList.iterator(); i.hasNext(); ) {
    String item = i.next();
    System.out.println(item);
  }
  </code></pre>
  
  <p>But as far as I can tell this cant be used for an Arraylist of a custom object.</p>
  
  <p>Can, and if so how can I implement a foreach loop for an ArrayList of a custom object?
  Or how could I otherwise process each item?</p>