@Test public void wheIterateTwoTimeArrayThenResultSecondPrimeNumber() { PrimeNumberIterator primeIt = new PrimeNumberIterator(testArray); final int expectedNumber = 5; primeIt.next(); int result = (Integer) primeIt.next(); assertThat(result, is(expectedNumber)); }
@Override public Object next() { Integer result = null; if (hasNext()) { for (int ind = index; ind < values.length; ind++) { if (isPrime(values[ind])) { result = values[ind]; index = ind + 1; break; } } } return result; }
PrimeNumberIterator implements Iterator { @Override public Object next() { Integer result = null; if (hasNext()) { for (int ind = index; ind < values.length; ind++) { if (isPrime(values[ind])) { result = values[ind]; index = ind + 1; break; } } } return result; } }
PrimeNumberIterator implements Iterator { @Override public Object next() { Integer result = null; if (hasNext()) { for (int ind = index; ind < values.length; ind++) { if (isPrime(values[ind])) { result = values[ind]; index = ind + 1; break; } } } return result; } PrimeNumberIterator(int[] values); }
PrimeNumberIterator implements Iterator { @Override public Object next() { Integer result = null; if (hasNext()) { for (int ind = index; ind < values.length; ind++) { if (isPrime(values[ind])) { result = values[ind]; index = ind + 1; break; } } } return result; } PrimeNumberIterator(int[] values); @Override boolean hasNext(); @Override Object next(); }
PrimeNumberIterator implements Iterator { @Override public Object next() { Integer result = null; if (hasNext()) { for (int ind = index; ind < values.length; ind++) { if (isPrime(values[ind])) { result = values[ind]; index = ind + 1; break; } } } return result; } PrimeNumberIterator(int[] values); @Override boolean hasNext(); @Override Object next();  }