title: How can I iterate through an ArrayList of the different class objects to search for a specific class?
body: <p>How can I iterate through an ArrayList of the different class objects to search for a specific class?</p>
  <p>productionDate is an interface that is implemented in base classes.</p>
  <p>Here is the code but it doesn't print anything :)</p>
  <pre><code>ArrayList&lt;ProductionDate&gt; storage;
  
  public void search(Class c, int itemCount){
     if(storage.getClass() == c){
         for(ProductionDate d : storage){
             if(d instanceof ProductionDate &amp;&amp;
                     ((ProductionDate)d).getItemCount() &gt;= itemCount){
                       System.out.println(d);
             }
         }
     }
  }
  </code></pre>