Search:

Type: Posts; User: Norm

Search: Search took 0.12 seconds.

  1. Replies
    12
    Views
    1,295

    Re: How do I add an element to the end of an array?

    It would be Simpler to say - there is no way to make an existing array larger.
    You can copy its contents to another larger array.
  2. Replies
    12
    Views
    1,295

    Re: How do I add an element to the end of an array?

    It looks like arraycopy() saves you writing a loop. I don't see where it adds any elements to an existing array.
  3. Replies
    12
    Views
    1,295

    Re: How do I add an element to the end of an array?

    What method is that? I see a method that will copy array elements but none that will change the size of an existing array.
  4. Replies
    12
    Views
    1,295

    Re: How do I add an element to the end of an array?

    Depends what you mean by add. What if the element at that index was null?
    Arrays always have some value in all the slots. Initially they are null for arrays of objects.
  5. Replies
    12
    Views
    1,295

    Re: How do I add an element to the end of an array?

    That would put the object at the last element in the array.

    Try it and see what happens.
  6. Replies
    12
    Views
    1,295

    Re: How do I add an element to the end of an array?

    theArray[theIndexToEnd] = anObject; // add an object to the end

    You need the index of where you want to add the object and then use it with the array.
Results 1 to 6 of 6