Arraylist for subclasses : <p>I have a Vehicle superclass and then I have some subclasses to that one. I am trying to have an array list that adds objects from all of the subclasses into the same list, but I'm coming up short.</p>

<p>I currently have the list in my program class but I have moved it around a bit.</p>

<p>This is the code I have in Program:</p>

<pre><code>ArrayList&lt;Vehicles&gt; Inventorie = new ArrayList&lt;&gt;();

public void setInventorie(Car newCar) {
    Inventorie.add(newCar);
}
</code></pre>

<p>And this the code I have in Car:</p>

<pre><code>public void addCar(){
    System.out.println("Make: ");
    Make = scan.nextLine();
    System.out.println("RegNr");
    regNr = scan.nextInt();
    System.out.println("Year");
    year = scan.nextInt();
    setValue();
    Car c1 = new Car(make, regNr, Year);
     Program.setInventorie(c1);
}
</code></pre>

<p>In Car I am getting "Non-static method 'setInventorie(Project1.Vehicles)' cannot be referenced from static context."</p>

<p>I also had to comment out the main method or the compiler couldn't resolve the symbol Inventorie (name of array list).</p>

<p>Tried to explain my problem as best as I could, hope someone can help.
And yes, I am new to this so it might seem really stupid but it's the best I could do.</p>

<p>Thanks</p>
