Trying to use polymorphism and ArrayList in java
<p>I have to use Polymorphism and ArrayList in my assignment in java but i need help. I would really appreciate it if anyone could help me. I can't acces my subclass methods from ArrayLis.</p>

<p>So I have a superclass</p>

<pre><code>    public class Table{
    private int TotalAmount;
    //setters and getters
    }
</code></pre>

<p>And I have two subclasses</p>

<pre><code>    public class TableFidelity extends Table{
    private int Points;
    //setters and getters
    }


    public class TableCompany extends Table{
    private int NumberOfTimesServed;
    //setters and getters
    }
</code></pre>

<p>I have to use both my subclasses in the same ArrayList</p>

<pre><code>    public static void main(String[] args){
    Table table=new Table();
    ArrayList&lt;Table&gt; Tables=new ArrayList&lt;Table&gt;();
    Table tablefidelity =new TableFidelity ();
    Table tablecompany =new TableCompany ();
    Tables.add(tablefidelity);
    Tables.add(tablecompany);
    System.out.println(Tables.get(0).getTotalAmount());
    //I can get the total Amount from the superclass
    System.out.println(Tables.get(0).getPoints());
    //but I can't do this
    System.out.println(Tables.get(1).NumberOfTimesServed());
    //or this 
    }
</code></pre>

<p>Netbeans dosen't show getPoints or NumberOfTimesServed when I press . it shows only the superclass methods.</p>