ArrayUtil { public static String[] listToArray(List<String> list) { if (list == null) return null; String[] array = new String[list.size()]; for (int i = 0; i < array.length; i++) { array[i] = list.get(i); } return array; }  static boolean isEmpty(Collection<?> collection); static boolean isEmpty(Object[] array); static String[] listToArray(List<String> list);  }
@Test public void testListToArray() { String[] strings1 = new String[] { "1", "2", "3" }; String[] strings2 = ArrayUtil.listToArray(Arrays.asList(strings1)); Assert.assertTrue(strings1.length == strings2.length); for (int i = 0; i < strings1.length && i < strings2.length; i++) { Assert.assertTrue(strings1[i].equals(strings2[i])); } }