Generic method with abstract class as parameter
<p>Hi I am trying to create a generic method that takes in a parameter which type is an abstract parameterised class. Inside the method I want to create a instances of the passed parameter given it is a subclass of the abstract type since we cannot instantiate abstract classes.</p>

<p>However I am having some issues.  And the error message says the RuleType cannot be resolved to a type which is not surprising anyway but I don’t know how can I accomplish this.
My current code is below.</p>

<pre><code>private &lt;F extends AbstractRule&lt;T&gt;, T&gt; void applyRyle(F cRule,ArrayList&lt;T&gt; aFeatures)
{

    Class RuleType = cRule.getClass();


    // if the parameter passed is a subclass of AbstractRule create some objects
    if(!RuleType.getSuperclass().getName().equals("AbstractRule"))
    {
        ArrayList&lt;RuleType&lt;T&gt;&gt; aRules = new ArrayList&lt;RuleType&lt;T&gt;&gt;();
        for(int i = 0; i &lt; 10; i++)
        {

            RuleType&lt;T&gt; aRule= new RuleType&lt;T(pattern.getMatrices().size(), 2,aFeatures);
            aRule.initialise(aRule.getMaxLocalLevel());
            aRules.add(aRule);
        }
    }
</code></pre>
