I agree with copeg, the use of a set would be much more efficient; such as HashSet (if you dont care about the order) or a LinkedHashSet (if you want to maintain insertion order).