package com.greensnow25.EvenNumbers;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

/**
 * public class EvenNumbers.
 *
 * @author greensnow25.
 * @version 1.
 * @since 12.04.2017.
 */
public class EvenNumbers implements Iterator {
    /**
     * array
     */
    private final int[] array;
    /**
     * position in the array.
     */
    int value = 0;

    /**
     * class constructor.
     *
     * @param array int array.
     */
    public EvenNumbers(int[] array) {
        this.array = array;
    }

    /**
     * the method checks whether the array contains a number that is divisible by two.
     *
     * @return true if array contain the even number..
     */
    @Override
    public boolean hasNext() {

        boolean result = false;
        for (int i = value; i != array.length; i++) {
            if (array[i] % 2 == 0) {
                result = true;
                break;
            }
        }
        return result;
    }

    /**
     * the method checks whether the array contains a number that is divisible by two.
     *
     * @return even number.
     */
    @Override
    public Object next() {
        Integer res = 0;
        for (int i = value; ; i++) {
            if (array[i] % 2 == 0) {
                res = array[i];
                value = ++i;
                break;
            }
        }
        return res;
    }

}

@@ -791,222 +791,280 @@
     
-boolean result = false
+return this.check() %3E 0
 ;%0A    
+%7D%0A%0A
     
-for (int i = value; i != array.length; i++) %7B%0A            if (array%5Bi%5D %25 2 == 0) %7B%0A  
+/**%0A     * the method checks whether the array contains a number that is divisible by two.%0A
      
+*%0A
      
-    result = true;%0A                break;%0A            %7D%0A        %7D%0A        return result
+* @return even number.%0A     */%0A    @Override%0A    public Object next() %7B%0A        this.check();%0A        return (Integer) array%5Bvalue++%5D
 ;%0A  
@@ -1078,36 +1078,32 @@
   /**%0A     *
- the
  method 
 checks wheth
@@ -1094,156 +1094,103 @@
 hod 
-checks whether the array contains a number that is divisible by two.%0A     *%0A     * @return even number.%0A     */%0A    @Override%0A    public Object next
+move pointer on position.%0A     *%0A     * @return position in array.%0A     */%0A    public int check
 () %7B
@@ -1202,23 +1202,20 @@
     
-I
+i
 nt
-eger
  res = 
-0
+-1
 ;%0A  
@@ -1240,16 +1240,33 @@
  value; 
+i != array.length
 ; i++) %7B
@@ -1323,22 +1323,17 @@
     
-res = array%5Bi%5D
+value = i
 ;%0A  
@@ -1350,19 +1350,15 @@
     
-value = ++i
+res = 1
 ;%0A  
@@ -1428,11 +1428,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

Update date 05.05.17