Results 1 to 2 of 2

Thread: Array question

  1. #1
    TheRockIng is offline Member
    Join Date
    Feb 2015
    Rep Power

    Default 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?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: Array question

    That seems a bit vague as a requirement, but it could mean simply create one Cellphone (which will go into slot 0 possibly) and then use a copy constructor to fill the other 9 slots, in a loop.
    It doesn't say how many unique values should be used.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Question about array
    By monching in forum AWT / Swing
    Replies: 6
    Last Post: 10-15-2014, 01:24 PM
  2. Array question
    By Jbo in forum New To Java
    Replies: 3
    Last Post: 09-02-2012, 08:46 AM
  3. Array Question
    By mamba24 in forum New To Java
    Replies: 6
    Last Post: 06-04-2012, 08:59 PM
  4. Question about a 2d array example
    By silverglade in forum New To Java
    Replies: 8
    Last Post: 06-06-2011, 11:56 PM
  5. array question
    By dazednconfused in forum New To Java
    Replies: 4
    Last Post: 09-15-2009, 05:44 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts