title: How can I implement the Iterable interface?
body: <p>Given the following code, how can I iterate over an object of type ProfileCollection?</p>
  
  <pre><code>public class ProfileCollection implements Iterable {    
      private ArrayList&lt;Profile&gt; m_Profiles;
  
      public Iterator&lt;Profile&gt; iterator() {        
          Iterator&lt;Profile&gt; iprof = m_Profiles.iterator();
          return iprof; 
      }
  
      ...
  
      public Profile GetActiveProfile() {
          return (Profile)m_Profiles.get(m_ActiveProfile);
      }
  }
  
  public static void main(String[] args) {
       m_PC = new ProfileCollection("profiles.xml");
  
       // properly outputs a profile:
       System.out.println(m_PC.GetActiveProfile()); 
  
       // not actually outputting any profiles:
       for(Iterator i = m_PC.iterator();i.hasNext();) {
          System.out.println(i.next());
       }
  
       // how I actually want this to work, but won't even compile:
       for(Profile prof: m_PC) {
          System.out.println(prof);
       }
  }
  </code></pre>