public boolean hasNext() {
// TODO Auto-generated method stub
return current != null;
}
public T next() throws NoSuchElementException {
if (!hasNext())
throw new NoSuchElementException();
else
prev = current;
current = current.next;
return (T) prev.data;
}
//This is my linked list
f.add(132);
f.add(133);
//while loop I am using in regular main method to test
while(f.iterator().hasNext()){
System.out.println(f.iterator().next());
}
For some reason I just get an infinite loop here and I am not sure why. I ran this in my main method and it just kept printing 132, I am not sure what's wrong.