End of Year Sale: Use Coupon Code END2025 to Get Extra 25% Off.
peek method to check if we have a peeked value. If not, retrieve the next element from the iterator and set the flag.next method to return the peeked value if available, or retrieve the next element from the iterator. Update the peeked value and flag accordingly.hasNext method to return true if we have a peeked value or if the iterator has a next element.