### Question:
Util { public static <K, V> Map<K, V> toMap(K[] keys, V[] values) { int keysSize = (keys != null) ? keys.length : 0; int valuesSize = (values != null) ? values.length : 0; if (keysSize == 0 && valuesSize == 0) { return new HashMap<>(); } if (keysSize != valuesSize) { throw new IllegalArgumentException("The number of keys doesn't match the number of values."); } Map<K, V> map = new HashMap<>(); for (int i = 0; i < keysSize; i++) { map.put(keys[i], values[i]); } return map; }  static File toFile(URL url); static String stringFromFile(File file); static String stringFromFile(File file, String joinWith); static String join(Iterable<?> objects, String separator); static String substBackslashes(String string); static Throwable unwindException(Throwable th); static boolean nullSafeEquals(Object o1, Object o2); static int nullSafeCompare(boolean nullsFirst, Comparable<T> o1, T o2); static boolean isEmptyString(CharSequence string); static boolean isBlank(CharSequence cs); static boolean isNumeric(CharSequence cs); static int countMatches(final String str, final String sub); static String capitalized(String name); static String uncapitalized(String aString); @SuppressWarnings("unchecked") static T cloneViaSerialization(T object); static XMLReader createXmlReader(); static Document readDocument(URL url); static String getPackagePath(String className); static String stripPackageName(String className); static Map<K, V> toMap(K[] keys, V[] values); static String extractFileExtension(String fileName); static String stripFileExtension(String fileName); static String stripLineBreaks(String string, char replaceWith); static String encodeXmlAttribute(String string); static String prettyTrim(String str, int maxLength); static Iterator<T> sortedIterator(Iterator<T> it, Comparator<T> comparator); static int hashCode(Collection<?> c); static Pattern sqlPatternToPattern(String pattern, boolean ignoreCase); static boolean isAccessible(Member member); @Deprecated static Class<?> getJavaClass(String className); static String underscoredToJava(String name, boolean capitalize); static String specialCharsToJava(String string);  }### Answer:
@Test public void testToMap() { Object[] keys = new Object[] { "a", "b" }; Object[] values = new Object[] { "1", "2" }; Map<Object, Object> map = Util.toMap(keys, values); assertEquals(2, map.size()); assertEquals("1", map.get("a")); assertEquals("2", map.get("b")); map.put("c", "3"); Map<Object, Object> emptyMap = Util.toMap(null, new Object[0]); assertTrue(emptyMap.isEmpty()); emptyMap.put("key1", "value1"); Object[] values2 = new Object[] { "1" }; try { Util.toMap(keys, values2); fail("must have thrown"); } catch (IllegalArgumentException e) { } }