The class below has a static method which sets all elements of an array to a value. The method is written for an array of strings. This will cause the method to not compile when invoked on arrays of other types. You will need to modify it so that it works for any type.

Complete the following file:

public class GenericArray { /** @param array is a generic array @param value all array elements are set to this value */ public static void setAll(String[] array, String value) { for (int i = 0; i < array.length; i++) array[i] = value; } }

Use the following file:

import java.util.Arrays;

public class GenericArrayTester
   public static void main(String[] args)
      String[] a1 = new String[3];
      GenericArray.setAll(a1, "Hello");
      System.out.println("Expected: [Hello, Hello, Hello]");
      Integer[] a2 = new Integer[5];
      GenericArray.setAll(a2, 42);
      System.out.println("Expected: [42, 42, 42, 42, 42]");