+5 votes
in Programming by Expert (3.8k points)
How can i Store an object in array?

1 Answer

+1 vote
by (1.8k points)
selected by
Best answer

i am here Initialising an array which will populates all positions with default value, array of objects the default value = null. see this code :

Customer[] cst = new Customer[3];

creates the following array:

{null, null, null}

There are several way to initialising arrays, but in case of 3 element array you can use this one:

Customer cst[] = {new Customer(), new Customer(), new Customer()};

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated