I think from your code that you are using an ArrayList (if not please correct me).
First of all, you are sort of man-handling it to keep track of the index yourself. Normally you would just check the ArrayList with the contains() method to see if the word is aready in the array, and you would use the size() method to keep track of how many elements are in the list.
However, assuming that you have some wise and wonderful reason for tracking it yourself, the following code will work for you. I took the liberty of changing the WordElem to a
String for ease of
testing, and changing the full test to an if statement, and using the add() method for ArrayList: