### Question:
ArrayUtils { public static Object getFirstMatch(Object[] array, Class clazz) { if (array == null || clazz == null) { return null; } Optional<Object> first = Arrays.stream(array) .filter(s -> clazz.isAssignableFrom(s.getClass())) .findFirst(); return first.orElse(null); }  static Object getFirstMatch(Object[] array, Class clazz);  }### Answer:
@Test public void getFirstMatch() { Object[] array = new Object[]{ new ArrayList<String>() { { add("第一个ArrayList"); } }, new HashMap<>(), new ArrayList<String>() { { add("第二个ArrayList"); } }, }; Object firstList = ArrayUtils.getFirstMatch(array, List.class); System.out.println(firstList); Assertions.assertTrue(firstList instanceof List); Assertions.assertTrue(firstList instanceof ArrayList); Assertions.assertEquals("第一个ArrayList", ((List) firstList).get(0)); System.out.println(((List) firstList).get(0)); Object firstMap = ArrayUtils.getFirstMatch(array, Map.class); Assertions.assertTrue(firstMap instanceof Map); System.out.println(firstMap); Object firstSet = ArrayUtils.getFirstMatch(array, Set.class); System.out.println(firstSet); }