### Question:
ArrayUtil { public static Object flatten(Object array) { Preconditions.checkArgument(array.getClass().isArray(), "array"); Class<?> type = getType(array); int[] dimensions = getDimensions(array); int length = length(dimensions); Object flattened = Array.newInstance(type, length); flatten(array, flattened, dimensions, 0); return flattened; }  static Object flatten(Object array); static Object unflatten(Object array, int[] dimensions); static int[] getDimensions(Object array); static Class<?> getType(Object array);  }### Answer:
@Test(dataProvider = "arrays") public void testFlatten(Object array) throws Exception { Object flattened = ArrayUtil.flatten(array); for (int i = 0; i < Array.getLength(flattened); i++) { assertEquals(Array.get(flattened, i), i); } }