title: Android generic property
body: <p>I have on object, where one property should be possible go store generic objects. All this objects extend a basic class "BaseObject".
  But there are a lot of object that extend "BaseObject" and the property should be able to store all kind of these...</p>
  
  <p>In Swift(iOS) I simply define a property as "AnyObject" like this:</p>
  
  <pre><code>class StoreObject
  {
      var object: AnyObject?
      var list: Array&lt;AnyObject&gt;?
  }
  </code></pre>
  
  <p>In Java, I tried it with this: (short version)</p>
  
  <pre><code>public class StoreObject
  {
      // this should store one of the objects
      public Class&lt;? extends BaseObject&gt; object = null;
  
      // this should store a list(all the same type) of the objects
      public ArrayList&lt;? extends BaseObject&gt; list = null;
  }
  </code></pre>
  
  <p>But this is not working :(</p>
  
  <p>Example:</p>
  
  <pre><code>StoreObject store = new StoreObject();
  store.object = new TextObject; // TestObject extends BaseObject
  </code></pre>
  
  <p>And here I get this error:</p>
  
  <pre><code>java.lang.ClassCastException: TestObject cannot be cast to java.lang.Class
  </code></pre>
  
  <p>Can somebody give me a hint on this?</p>
  
  <p>Thanks,
  Urkman</p>