1: // @author Frank M. Carrano, Timothy M. Henry 2: // @version 5.0 4: /** Searches an array for anEntry. */ 5: public static <T> boolean inArray(T[] anArray, T anEntry) 6: { 7: return search(anArray, 0, anArray.length - 1, anEntry); 8: } // end inArray 10: // Searches anArray[first] through anArray[last] for desiredItem. 11: // first >= 0 and < anArray.length. 12: // last >= 0 and < anArray.length. 13: private static <T> boolean search(T[] anArray, int first, int last, T desiredItem) 14: { 15: boolean found; 16: if (first > last) 17: found = false; // No elements to search 18: else if (desiredItem.equals(anArray[first])) 19: found = true; 20: else 21: found = search(anArray, first + 1, last, desiredItem); 22: 23: return found; 24: } // end search