why does iterator not enforce hasnext call?
It seems quite a good method if hasNext and Next worked something like this:
boolean hasNextCalled = false;
boolean hasNext() {
hasNextCalled = true
}
next() {
assert hasNextCalled
}
This way we would never land up with a case where we would get
NoSuchElementException(). Any practical reason why hasNext() call is not
enforced ?
No comments:
Post a Comment