Searching in a list is O(n): you have to iterate through every element until you find the one which matches.
If the list is sorted by date, you can use Collections.binarySearch()
, which will make the process O(log(n)) (so, faster unless the list is very very small, in which case it doesn't matter).
You couldalso use a TreeSet, which would maintain the holidays sorted, and would allow searching in O(log(n)) time as well.
Or you could use a HashSet, which would make the search O(1) (constant time), but wouldn't maintain its elements sorted.