Monday, April 13, 2015

Array question


Hey guys,


So this is not a question about HOW to make arrays, but more how to do the following instruction:


Create an array of 10 cell phones. All these cell phones must be initialized with

proper values; that is: brand, price & serial number. You must use the copy

constructor to create some of these objects


How would I go about to do this? I know I can create an array of object from my class like this



Java Code:



Cellphone[] cellphoneArr = new Cellphone[10];

but then would I have to initialize 5 of them and then use the copy constructor to copy the 5 others? Or is there any faster way to do this? For instance create 5 then use a loop to copy the first 5 into the 5 left?

No comments:

Post a Comment