Re: Iterator, with ArrayList
Add a cast.
Code :
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 ignore the warning.
Re: Iterator, with ArrayList
xD
I found a solution a little while ago :O
by setting the type of the iterator, didnt know i could do it.
Code :
Iterator<word> itr = words.iterator();
thanks though
Re: Iterator, with ArrayList
You can also use a special for loop syntax that automatically handles iterators.
Code :
for (word w : words) {
System.out.println(w.getWord());
}