package ru.job4j.pro.iterator.array;

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

/**
 * This class implements iterator of double array.
 *
 * @author Kucykh Vasily (mailto:basil135@mail.ru)
 * @version $Id$
 * @since 23.05.2017
 */
public class ArrayIterator implements Iterator<Integer> {

    /**
     * parameter index of column.
     */
    private int indexCol = 0;
    /**
     * parameter index of row.
     */
    private int indexRow = 0;
    /**
     * parameter doubleArray is double array.
     */
    private final Integer[][] doubleArray;

    /**
     * constructor of class.
     *
     * @param doubleArray is input double array
     */
    public ArrayIterator(final Integer[][] doubleArray) {
        this.doubleArray = doubleArray;
    }

    /**
     * method return true if doubleArray have next value.
     *
     * @return true if array have next value
     */
    @Override
    public boolean hasNext() {
        boolean result = true;

        if (indexRow == doubleArray.length - 1 && indexCol == doubleArray[indexRow].length) {
            result = false;
        }

        return result;
    }

    /**
     * method return Integer number of position indexCol and indexRow, then increment one of them.
     *
     * @return Integer number as value
     */
    @Override
    public Integer next() {

        if (!hasNext()) {
            throw new NoSuchElementException();
        }

        Integer result;

        if (indexCol == doubleArray[indexRow].length) {
            indexCol = 0;
            indexRow++;
        }

        result = doubleArray[indexRow][indexCol++];

        return result;

    }

}

@@ -961,43 +961,16 @@
     
-boolean result = true;%0A%0A        if 
+return !
 (ind
@@ -1049,71 +1049,8 @@
 gth)
- %7B%0A            result = false;%0A        %7D%0A%0A        return result
 ;%0A  

Refactor ArrayIterator.java upgrade condition at method hasNext()