title: Create arraylist of class and interface
body: <p>I'm attempting to create an <code>ArrayList</code> (so java, obviously) with type <code>TileEntity</code> (yes this is a minecraft mod). But I also need the objects added to the <code>ArrayList</code> to implement a certain interface. </p>
  
  <p>The first option that came to mind was creating an abstract subclass of <code>TileEntity</code> that implemented interface, and using that as the <code>ArrayList</code> type. But given the fact that people normally create their own subclasses of <code>TileEntity</code> and use those as the class they normally subclass, and I want people to be able to hook into my mod, I can't expect them to subclass anything besides <code>TileEntity</code>. </p>
  
  <p>My current solution is to check <code>if(object instanceof MyInterface)</code> before adding, but that seems ugly. Surely there's a way to set the type of an <code>ArrayList</code> to require that an object be both a subclass of <code>TileEntity</code> and an implementor of <code>MyInterface</code>.</p>