Creating a data type class that has different implementations depending on size of given list in Java
<p>So I'm trying to create a data type class that has different configurations depending on the size of a list given in the main. It's a data type for house listings and the idea is if the number of house listings(size) is greater than 1000, I'd have the data type called SmartULS be implemented using a tree or AVL tree.</p>

<p>On the other hand, if it's smaller than 1000, let it be implemented using a hash table. The idea is to make sorting/get/set/removing faster depending on the size of the list given.</p>

<p>I've worked this out so far, but it's not working:</p>

<pre><code>   public class houseListings&lt;K,V&gt; {

    protected TreeMap&lt;K,V&gt; tree = new TreeMap&lt;&gt;();
    protected AbstractHashMap&lt;K,V&gt; hashMap = new AbstractHashMap&lt;K,V&gt;();

    public void setHouseListings(size){
        int threshold = 1000;
        if (size &gt;= threshold) {
             map = new AbtractMap&lt;K,V&gt;();
        }
        else
             map = new TreeMap&lt;K,V&gt;();

    }
}
</code></pre>