Code example for Iterator

Methods: hasNext, next

0
        this.iterator = iterator;
        advance(); 
    } 
     
    private void advance() { 
        this.next = iterator.hasNext() ? iterator.next() : null;
    } 
     
    public T peek() { 
        return next;
    } 
     
    /** 
     * {@inheritDoc} 
     */ 
    @Override 
    public boolean hasNext() { 
        return next != null;
    } 
     
    /**