Q:

Most efficient way to enter data in array

I'm making a program which has an option to let the user enter data into an array.
For example the option will ask the user to enter the make and model of a car which
will then be stored as an element in an array. I want to know how I can let the program enter
the next car as a different element each loop. For example:
Loop 1:
Enter car details
( stored as myArray[1] )
back to start
Loop 2: Enter car details
( stored as myArray[2] )
etc..
what is the most efficient way to do this?

A:

I assume you have object named Car, that contains it's make and mode.
Also I suppose you have method Car readCar() that creats new Car somehow.
See code snipped that creates arraya of Car objects and populates it:
int carsNumber = 10;//number of cars
Car [] cars = new Car[carsNumber];//creates empty array (10 null)
for (int i = 0; i < cars.length; i++)
{
    Car c = readCar(make,model);//creates Car somehow
    cars[i] = c;//populates current car in array, i++ command will move to next index
}

