package ru.job4j.even.numbers.iterator;

import java.util.Iterator;
import java.util.NoSuchElementException;

public class EvenNumbersIterator implements Iterator {
    private int[] numbers;
    private int index = 0;
    private int size;

    public EvenNumbersIterator(final int[] numbers) {
        this.numbers = numbers;
        this.size = numbers.length;
    }

    @Override
    public boolean hasNext() {
        int pointer = index;
        while (pointer < size) {
            if (isEvenNumber(numbers[pointer])) {
                return true;
            } else {
                pointer++;
            }
        }
        return false;
    }

    @Override
    public Object next() {
//        if (size == 0 || !hasNext() || index > size) {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        int tmp = numbers[index];
        while (index < size) {
            if (isEvenNumber(tmp)) {
                index++;
                break;
            } else {
                tmp = numbers[++index];
            }
        }
        return tmp;
    }

    private boolean isEvenNumber(int num) {
        return num % 2 == 0;
    }
}

@@ -696,65 +696,8 @@
 ) %7B%0A
-//        if (size == 0 %7C%7C !hasNext() %7C%7C index %3E size) %7B%0A
     

Add a change to method.