Re: hasNext?
- From: Andreas Leitgeb <avl@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 28 Feb 2008 10:02:44 GMT
KyoGaSuki <jrockgadaisukidayou@xxxxxxxxxxx> wrote:
What is hasNext? I know you use it when you are reading from a file
and it will stop when it has nothing more to read, but how would you
use it? I have seen a couple of different examples of it, but all
they do is make me more confused. I just can't seem to understand
it...can anyone help?
e.g.:
Iterator x= ...;
while (x.hasNext()) {
... x.next() ...
}
You must make sure, that you only call ".next()" if the
previous ".hasNext()" returned true. You also shouldn't
call .next() more than once in the loop, except if you
also check again for .hasNext() .
.
- References:
- hasNext?
- From: KyoGaSuki
- hasNext?
- Prev by Date: cursor problem in swing component...
- Next by Date: Re: do u know ramanujan numbers algorithm
- Previous by thread: hasNext?
- Next by thread: Re: hasNext?
- Index(es):