Java class variable number -


i'm learning java , have question.

i created class named "driver" , hold driver's information (name , birthday).

to create new driver need do:

driver d1 = new driver("john", "01/01/1980"); 

now imagine have program read x drivers information file. how can create x drivers?

my problem i'm thinking need x variables x drivers variables can hard-coded me...

or can use array or collection (list or set):

list<driver> drivers = new arraylist<driver>(); drivers.add(new driver(..)); drivers.add(new driver(..)); 

when reading file use loop. on each iteration add object list.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -