Add a cast.


temp = ((word)itr.next()).getWord();

You might get a warning that says this is a potentially unsafe cast, but since you know that the iterator can only return a word, you can...