@Test public void combineMethodShouldCombineTwoArraysUpToMaxSizeWhenMaxSizeLessThanArray1Elements() { String[] array1 = {"one", "two", "three"}; String[] array2 = {"four", "five", "six"}; String[] combinedArray = combine(array1, array2, 2); for (int i = 0; i < combinedArray.length; i++) { Assert.assertEquals(array1[i], combinedArray[i]); } Assert.assertEquals(2, combinedArray.length); }
@SuppressWarnings("unchecked") public static <T> T[] combine(T[] array1, T[] array2) { return combine(array1, array2, array1.length + array2.length); }
ArrayUtils { @SuppressWarnings("unchecked") public static <T> T[] combine(T[] array1, T[] array2) { return combine(array1, array2, array1.length + array2.length); } }
ArrayUtils { @SuppressWarnings("unchecked") public static <T> T[] combine(T[] array1, T[] array2) { return combine(array1, array2, array1.length + array2.length); } private  ArrayUtils(); }
ArrayUtils { @SuppressWarnings("unchecked") public static <T> T[] combine(T[] array1, T[] array2) { return combine(array1, array2, array1.length + array2.length); } private  ArrayUtils(); @SuppressWarnings("unchecked") static T[] combine(T[] array1, T[] array2); @SuppressWarnings("unchecked") static T[] combine(T[] array1, T[] array2, int maxElements); }
ArrayUtils { @SuppressWarnings("unchecked") public static <T> T[] combine(T[] array1, T[] array2) { return combine(array1, array2, array1.length + array2.length); } private  ArrayUtils(); @SuppressWarnings("unchecked") static T[] combine(T[] array1, T[] array2); @SuppressWarnings("unchecked") static T[] combine(T[] array1, T[] array2, int maxElements);  }