How can we select the good subclass for the result without using instanceof?
<p>When I try this code, I have 2 possibilities for the result in "tab". But the program choose the result "Null" of "Repository" instead of the ArrayList of "ChooseRepository". How Can I specify that I want the result for "ChooseRepository" and not the result for "Repository" without using "instanceof"?
Note that "ChooseRepository" is a subclasse of Repository.</p>

<pre><code>ChooseRepository chooseRepository = new ChooseRepository(this); 
tab = searchTab("H","US",chooseRepository);

public ArrayList&lt;String&gt; searchTab(String sexe,String SI,Repository&lt;?&gt; repository){
    ArrayList&lt;String&gt; tab;
    repository.Open();
    repository.rechercherspin(sexe);

    tab=  repository.taillesUS;

    return tab;
}
</code></pre>
