title: Java: ArrayList returns Object instead of desired type
body: <p>I'm having a problem that I have encountered before, but I still don't know why it happens.
  This is the code:</p>
  
  <pre><code>package Program;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  
  /**
   * This class will hold the full collection of the user.
   *
   * @author Harm De Weirdt
   */
  public class ShowManager {
  
      /**
       * The collection of shows of this user.
       */
      private ArrayList&lt;Show&gt; collection;
  
      private static final ShowManager INSTANCE = new ShowManager();
  
      // Private constructor prevents instantiation from other classes
      private ShowManager() {
         collection = new ArrayList&lt;Show&gt;();
      }
  
      public static ShowManager getInstance() {
        return INSTANCE;
      }
  
      private ArrayList&lt;Show&gt; getCollection() {
          return collection;
      }
  
      /**
       * Add a new Show to the collection
       *
       * @param newShow
       *      The show to be added
       * @post if &lt;newShow&gt; was not null and the collection didn't already contain
       *      &lt;newShow&gt;, &lt;newShow&gt; was added to the collection
       *      |getCollection().contains(&lt;newShow&gt;)
       */
      public void addShow(Show newShow){
         if(newShow != null &amp;&amp; !getCollection().contains(newShow)){
             getCollection().add(newShow);
         }
      }
  
      /**
       * Gives the amount of shows this user has in his collection.
       *
       * @return the size of &lt;collection&gt;.
       */
      public int getShowCount(){
          return getCollection().size();
      }
  
      public int getSeasonsCount(){
          Iterator it = getCollection().iterator();
          int amount = 0;
          while(it.hasNext()){
              amount += it.next().getSeasonCount();
          }
          return amount;
      }
   }
  </code></pre>
  
  <p>The problem is with the getSeasonsCount method. 
  the it.next() returns an Object instead of a Show object.
  As far as I know, this is a matter of generics, but I specified that the collection ArrayList is a list of Show objects, so I really don't see what is wrong here.</p>
  
  <p>Can anyone help me? </p>
  
  <p>Harm</p>