### Question:
Util { static <T> List<T> asArrayList(final int length) { List<T> list = new ArrayList<>(length); for (int i = 0; i < length; ++i) { list.add(null); } return list; } private  Util();   }### Answer:
@Test public void testAsArrayList_nullArray() { assertTrue(Util.asArrayList((Object[]) null).isEmpty()); assertTrue(Util.asArrayList((byte[]) null).isEmpty()); assertTrue(Util.asArrayList((boolean[]) null).isEmpty()); assertTrue(Util.asArrayList((short[]) null).isEmpty()); assertTrue(Util.asArrayList((char[]) null).isEmpty()); assertTrue(Util.asArrayList((int[]) null).isEmpty()); assertTrue(Util.asArrayList((float[]) null).isEmpty()); assertTrue(Util.asArrayList((long[]) null).isEmpty()); assertTrue(Util.asArrayList((double[]) null).isEmpty()); }
@Test public void testAsArrayList_withLength() { List<String> strings = Util.asArrayList(3); assertEquals(3, strings.size()); assertNull(strings.get(0)); assertNull(strings.get(1)); assertNull(strings.get(2)); }
@Test public void testAsArrayList_withLengthAndArray() { List<Integer> ints = Util.asArrayList(3, new Integer[] {1, 2, 3, 4, 5}); assertEquals(3, ints.size()); assertEquals(Integer.valueOf(1), ints.get(0)); assertEquals(Integer.valueOf(2), ints.get(1)); assertEquals(Integer.valueOf(3), ints.get(2)); }