how to iterate through a list in salesforce
<p>I am new to salesforce, I want to iterate the department images, can anyone help me?</p>

<p>Here is the code:</p>

<pre><code> public class Hospital_Controller {
 public List&lt;attachment&gt; HodImages {get; set;}
 string recid;
 string recId1 ;
 public Hospital_Controller(ApexPages.StandardController controller) {
      recId = controller.getId();   
      HodImages  = new List&lt;attachment&gt;();
      List&lt;Department__c&gt; depIds =[select id from Department__c];
      HodImages = [select id,name from attachment where parentId =:depIds];

  }
}
</code></pre>