ArrayList of classes : ArrayList<Class> but how to force those classes to extend some super class?
<p>I want to manage an ArrayList of classes. </p>

<p>For instance, I have 3 types of filters : <code>TextFilter</code>, <code>DurationFilter</code> and <code>TimeFilter</code> which extend <code>Filter</code>. </p>

<p>That seems to be correct :</p>

<pre><code>List&lt;Class&gt; filters = new ArrayList&lt;Class&gt;();

filters.add(TextFilter.class);
filters.add(DurationFilter.class);
filters.add(TimeFilter.class);
</code></pre>

<p>But now I want to restrain the ArrayList type with </p>

<pre><code>List&lt;Filter.class&gt; filters = new ArrayList&lt;Filter.class&gt;();

filters.add(TextFilter.class);
filters.add(DurationFilter.class);
filters.add(TimeFilter.class);
</code></pre>

<p>But it seems that it is not correct. Can you explain why? Do you have a solution to only accept Filter child classes to be adde in my ArrayList? Thanks.</p>
