You could initialize *duplicateWords* as **Hashset**. So you won't need to use *.contains()* in line number 41 as **HashSet** only inserts unique data.