chapter_004/src/main/java/ru/job4j/iterator/Converter.java
/**
     * Method can to get iterator of iterators and  take iterator.
     *
     * @param it - iterator of iterators.
     * @return - iterator.
     */
Method can to get iterator of iterators and  take iterator.
@param it - iterator of iterators.
@return - iterator.
Method can to get iterator of iterators and take iterator . @param it - iterator of iterators . @return - iterator .
public Iterator<Integer> convert(Iterator<Iterator<Integer>> it) {
        return new Iterator<Integer>() {
            Iterator<Iterator<Integer>> iteratorIterator = it;
            Iterator<Integer> inside = iteratorIterator.next();
            private void check() {
                if (!this.inside.hasNext() && this.iteratorIterator.hasNext()) {
                    this.inside = this.iteratorIterator.next();
                }
            }
            @Override
            public boolean hasNext() {
                check();
                return inside.hasNext();
            }
            @Override
            public Integer next() {
                check();
                return this.inside.next();
            }
        };
    }
public Iterator < Integer > convert ( Iterator < Iterator < Integer > > it ) { return new Iterator < Integer > ( ) { Iterator < Iterator < Integer > > iteratorIterator = it ; Iterator < Integer > inside = iteratorIterator . next ( ) ; private void check ( ) { if ( ! this . inside . hasNext ( ) && this . iteratorIterator . hasNext ( ) ) { this . inside = this . iteratorIterator . next ( ) ; } } @ Override public boolean hasNext ( ) { check ( ) ; return inside . hasNext ( ) ; } @ Override public Integer next ( ) { check ( ) ; return this . inside . next ( ) ; } } ; }
Method can to get iterator of iterators and  take iterator.
Method can to get iterator of iterators and take iterator .