/** * Check if an array contains an element. * * @param array the array with all the elements * @param element the element to find in the array * @return {@code true} if the array contains the element */ public static boolean contains(Object[] array, Object element) { return indexOf( array, element ) != -1; }
@Test public void testIndexOf() { Object[] array = new Integer[]{ 1, 2, 3 }; Object element = 3; int expResult = 2; int result = ArrayHelper.indexOf( array, element ); assertEquals( expResult, result ); }