A Way Of Saying "For All Subclasses In My Project That Extend This Superclass"?
<p>Here's something that's got me a bit stumped but intrigued all the same. In my Android game I have various Levels that extend the superclass Level. What I am trying to do is build a levelDirectory (based on the Singleton DP) that essentially is an object that has a HashMap object within it that stores all the Level subclasses. Here is my question:</p>

<p>We're all familiar with the enhanced for loop, but how can I write something that would be the equivalent of</p>

<pre><code>for(Level l : An Array Of Every Level Subclass In My Project that is an Extension of the Level Superclass){

HashMap.put(l.name, l);

}
</code></pre>

<p>I am trying to build a system that can dynamically update itself when I add more and more level subclasses. I know having a method in Level that submitted itself to the static Directory and was called in the Level's constructor is an option, But I'm just wondering whether there is a way of doing what I said above in that enhanced for loop?</p>

<p>Many thanks</p>
