What's the difference b/w next() and hasNext()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2014 06:53 AM
- 34,850 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hi,
hasNext() just checked whether the query has return records or not , just a boolean return.
next() actually does moves the pointer to the first to next record in the iteration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
next () - we use when iterate in a loop and moves to the next record.
- Its return True (Boolean) - if successfully iterate to next record ( e.g post queried on GlideRecord)
- Typically used under While condition.
hasNext() - we use when we want to check whether next record exists or not.
Its return True(Boolean) - Next record exists.
Use under IF condition.
