Search:

Type: Posts; User: aesguitar

Search: Search took 0.12 seconds.

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

    Ok, so to add an element to the end of an array, you have to create a larger array and do some copying, so something like this:




    public static int[] addToArray(int[] arr, int ele, int...
  2. Re: How do I add an element to the end of an array?

    public static int[] addArray(int[] arr1, int[] arr2) //1.
    {
    int[] arrFin = new int[arr1.length+arr2.length]; //2.
    System.arraycopy(arr1, 0,...
  3. Re: How do I add an element to the end of an array?

    It would be the copy array method. It can easily be used to add elements to an array, or at least two arrays. Observe...



    public static int[] addArray(int[] arr1, int[] arr2)
    {
    int[]...
  4. Re: How do I add an element to the end of an array?

    Well, by add, I took it as you have array arr1[] with size 5 and you want to add a sixth element. If that's the case, then there's a method in System to do it for you.

    System (Java 2 Platform SE...
  5. Re: How do I add an element to the end of an array?

    Wouldn't that method set the object at that index to "anObject", that wouldn't add an element, only change it, right?
Results 1 to 5 of 5