This is the opposite:
Vehicle[] car = new Vehicle[N];
This is more important because the number of elements in the array is not part of the car
type, but it is part of the initialization of the array, the reference to which you originally assigned to car
. Then you can reassign it in another statement:
car = new Vehicle[10];
(Note that I changed the type name in accordance with the Java naming conventions.)
For more information about arrays, see section 10 of the Java Language Specification .
source share