Why is my array printing null? (Java)
<p>I created an array called idPlate in an abstract class called Vehicle:</p>

<pre><code>public abstract class Vehicle
{
    String[] idPlate = new String[20];

    public abstract void setIDPlate(String plate, int num);
    public abstract String getIDPlate(int num);
}
</code></pre>

<p>I have another class called Car which inherits Vehicle:</p>

<pre><code>public class Car extends Vehicle
{
    public void setIDPlate(String plate, int num)
    {
        idPlate[num] = plate;
    }

    public String getIDPlate(int num)
    {
        return idPlate[num];
    }
}
</code></pre>

<p>I want to write to the array from the class CarParkManager from the addVehicle method and print from the array using the listVehicles method:</p>

<pre><code>public class CarParkManager
{
    String returnToMenu = "Y";
    String[] vehicle = new String[20];

    public void menu()
    {
        while ("Y".equals(returnToMenu)) {
            System.out.println("*********Menu*********");
            System.out.println("Type appropriate number to select option:");
            System.out.println("1- Add new vehicle to Car Park");

            System.out.println("3- List Vehicles in Car Park");

            Scanner scan = new Scanner(System.in);
            String listnumber = scan.nextLine();

            if ("1".equals(listnumber)) {
                addVehicle(vehicle);
            }

            if ("3".equals(listnumber)) {
                listVehicles(vehicle);
            }
        }
    }

    private void addVehicle(String v[])
    {
        System.out.println("Enter car ID plate");
        Scanner input = new Scanner(System.in);
        String vehicleid;
        vehicleid = input.nextLine();

        for (int x = 0; x &lt; v.length; x++) {
            if (v[x] == null) {
                v[x] = "Car";
                Car car = new Car();
                car.setIDPlate(vehicleid, x);
                break;
            }
        }
    }

    public void listVehicles(String v[])
    {
        System.out.println("****List Vehicle in Car Park****");  

        for (int x = 0; x &lt; 20; x++) {
            if (v[x] == null) {
                System.out.println("Parking lot " + x + ": Vacant");
            }

            if (v[x] == "Car") {
                Car getcarid = new Car();
                System.out.println("Parking lot " + x + ": " + v[x] + ", ID-" + getcarid.getIDPlate(x));
            }
        }
    }
}
</code></pre>

<p>I'm able to print out from the vehicle array but the idPlate remains null and so the output is like:
Parking lot 0: Car, ID-null</p>