Exciting array review problems

public class Main {
    public static void main(String[] args) {
        int[] nums = new int[7];
        fiboize(nums);
        printInts(nums);
    }
}

Running the above code does the following:

  • Creates an array of seven integers
  • Assigns the first seven Fibonacci numbers into the array
  • Prints out the contents of the array
  • Write the methods fiboize and printInts such that they will work on any size array.

     

     

    Now consider the following code:

    public class Main {
        public static void main(String[] args) {
            int[][] nums = new int[4][6];
            populate(nums);
            printInts(nums);
        }
    }

    Write the method populate that sets each elements of nums to the product of the indices (i.e., nums[2][3] should be 6 because 2*3 = 6, nums[0][anything] should be 0 because 0*anything = 0).

    Then write another methd called printInts that takes a two-dimensional array of ints and prints them all out.