I get compile error when trying to use method of something i got off iterator.next()
first off, I have a class named word, it has a method called getWord which returns a String.
import //all needed packages public class unique { ArrayList<word> words = new ArrayList<word>(); public unique(.........) { //filling ArrayList with objects of type word. } private boolean checkForWord(String token) { Iterator itr = words.iterator(); String temp; while(itr.hasNext()) { temp = itr.next().getWord(); [COLOR="Red"]//COMPILE ERROR ON THE LINE ABOVE[/COLOR]:-q:-q:-q if(temp.equals(token)) return true; } return false; }
public class word { String token; public word (String token) { this.token = token; } public String getWord() { return token; } }
The compile error I receive is , cannot find method getWord()
Any ideas?
I suspect it may have something to do with iterator POSSIBLY returning type OBJECT ..but even if this is the case, how do I convert this back to a "usable" object of type word?