If what you're interested in is an exact match, you can sort your array with Arrays.sort and search it with Arrays.binarySearch. Check the API docs for java.util.Arrays.