public class ArrayMain {

  // Write a static method addArray that takes two arrays of integers
  // base and toAdd, and _changes_ the base by adding each corresponding
  // index of toAdd to the value already in base.  There is no return
  // value.
  // ASSUME: base and toAdd are the same length.
  /*
  public static void addArray(int[] base, int[] toAdd) {
    int[] added = new int[base.length];
    for(int i = 0; i < base.length; i += 1) {
      added[i] = base[i] + toAdd[i];
    }
    base = added;
  }
  public static void addArray(int[] base, int[] toAdd) {
    int[] added = base;
    for(int i = 0; i < base.length; i += 1) {
      added[i] = base[i] + toAdd[i];
    }
  }
  public static void addArray(int[] base, int[] toAdd) {
    for(int i = 0; i < base.length; i += 1) {
      base[i] = base[i] + toAdd[i];
    }
  }
  public static void addArray(int[] base, int[] toAdd) {
    for(int i = 0; i < toAdd.length; i += 1) {
      toAdd[i] = base[i] + toAdd[i];
    }
  }
  */

  public static void main(String[] args) {

    int[] arr = new int[5];
    int[] zeroElements = new int[0];

    int[] arr2 = {2, 4, 6, 8};
    int[] arr3 = {3, 4, 5, 6};

    arr[0] = 47;

    addArray(arr2, arr3);

    System.out.println(arr2[0] + " " + arr2[1]);
    System.out.println(arr3[0] + " " + arr3[1]);


    System.out.println(arr[0] + ", " + arr[1]);

    System.out.println("The length is: " + arr.length);

  }














  // Write a static method sum that takes an array of integers
  // and evaluates to the sum of the integers in the array
  /*
  public static int sum(int[] array) {
    int[] total = array;
    for(int i = 0; i < array.length; i += 1) {
      total[i] += array[i];
    }
    return total;
  }
  public static int sum(int[] array) {
    int total = array[0];
    for(int i = 1; i < array.length; i += 1) {
      total += array[i];
    }
    return total;
  }
  */
  public static int sum(int[] array) {
    int total = 0;
    for(int i = 0; i < array.length; i += 1) {
      total += array[i];
    }
    return total;
  }




















/*

  public static void addArray(int[] base, int[] toAdd) {
    int[] added = new int[base.length];
    for(int i = 0; i < base.length; i += 1) {
      added[i] = base[i] + toAdd[i];
    }
    base = added;
  }
  public static void addArray(int[] base, int[] toAdd) {
    int[] added = base;
    for(int i = 0; i < base.length; i += 1) {
      added[i] = base[i] + toAdd[i];
    }
  }
  public static void addArray(int[] base, int[] toAdd) {
    for(int i = 0; i < base.length; i += 1) {
      base[i] = base[i] + toAdd[i];
    }
  }
  public static void addArray(int[] base, int[] toAdd) {
    for(int i = 0; i < toAdd.length; i += 1) {
      toAdd[i] = base[i] + toAdd[i];
    }
  }

*/
}
