### Question:
ArrayUtil { public static long[] getLimited(long[] arr, int limit) { if (arr == null) { return arr; } if (arr.length > limit) { long[] result = new long[limit]; System.arraycopy(arr, arr.length - limit, result, 0, limit); return result; } else { return arr; } } private  ArrayUtil(); static Long[] toLongArr(String[] strArr); static Long[] toLongArr(long[] longArr); static long[] toRawLongArr(String[] strArr); static int[] toRawIntArr(String strArr[]); static long[] toLongArr(Collection<Long> ids); static int[] toIntArr(Collection<Integer> ids); static String[] splitSimpleString(String str); static String toSimpleString(long a[]); static void reverse(long[] b); static void reverse(long[][] b); static long[] reverseCopy(long[] original, int newLength); static long[] reverseCopyRange(long[] original, int from, int to); static long[] removeAll(long[] sourceArray, long[] removeArray); static long[] removeAll(long[] sourceArray, Set<Long> removeSet); static long[] sort(long left[], long right[]); static void sortDesc(long[] a); static long[] intersectionOrder(long[] arr1, long[] arr2); static long[] addTo(long[] left, long[] right); static long[] addTo(long[] arr, long id); static long[] addTo(long[] arr, long id, int limit); static long[] getLimited(long[] arr, int limit);  }### Answer:
@Test public void testGetLimited(){ long[] array1 = { 1, 2, 4, 6, 8, 15, 17 }; long[] array2 = { 1, 2, 4, 6, 8, 15, 17, 18, 19, 20, 21}; long[] array3 = null; long[] array4 = {}; int limit = 10; long[] result = ArrayUtil.getLimited(array1, limit); Assert.assertArrayEquals(new long[] { 1, 2, 4, 6, 8, 15, 17}, result); result = ArrayUtil.getLimited(array2, limit); Assert.assertArrayEquals(new long[] { 2, 4, 6, 8, 15, 17, 18, 19, 20, 21}, result); result = ArrayUtil.getLimited(array3, limit); Assert.assertArrayEquals(null, result); result = ArrayUtil.getLimited(array4, limit); Assert.assertArrayEquals(new long[]{}, result); }