### Question:
CollectionUtils { @SuppressWarnings("unchecked") public static <K, V> Map<K, V> toMap(Object... pairs) { Map<K, V> ret = new HashMap<K, V>(); if (pairs == null || pairs.length == 0) return ret; if (pairs.length % 2 != 0) { throw new IllegalArgumentException("Map pairs can not be odd number."); } int len = pairs.length / 2; for (int i = 0; i < len; i++) { ret.put((K) pairs[2 * i], (V) pairs[2 * i + 1]); } return ret; } private  CollectionUtils(); @SuppressWarnings({"unchecked", "rawtypes"}) static List<T> sort(List<T> list); static List<String> sortSimpleName(List<String> list); static Map<String, Map<String, String>> splitAll(Map<String, List<String>> list, String separator); static Map<String, List<String>> joinAll(Map<String, Map<String, String>> map, String separator); static Map<String, String> split(List<String> list, String separator); static List<String> join(Map<String, String> map, String separator); static String join(List<String> list, String separator); static boolean mapEquals(Map<?, ?> map1, Map<?, ?> map2); static Map<String, String> toStringMap(String... pairs); @SuppressWarnings("unchecked") static Map<K, V> toMap(Object... pairs); static boolean isEmpty(Collection<?> collection); static boolean isNotEmpty(Collection<?> collection);  }### Answer:
@Test public void toMap() throws Exception { Map<String, String> result; String[] names = new String[0]; result = CollectionUtils.toMap(names); Assert.assertTrue(result.size() == 0); try { CollectionUtils.toMap("sxp"); Assert.fail(); } catch (Exception e) { } result = CollectionUtils.toMap("sxp", "Smart", "Alice", "Pretty", "Bob", "Handsome"); Assert.assertTrue(result.size() == 3); Assert.assertTrue("Smart".equals(result.get("sxp"))); Assert.assertTrue("Pretty".equals(result.get("Alice"))); }