IteratorForEvenNumber implements Iterator { @Override public boolean hasNext() { int currentPosition = this.position; boolean result = false; do { if (this.value[currentPosition++] % 2 == 0) { result = true; break; } } while(currentPosition < this.value.length); return result; } IteratorForEvenNumber(int[] value); @Override boolean hasNext(); @Override Object next(); @Override void remove();  }
@Test public void hasNext() throws Exception { IteratorForEvenNumber it = new IteratorForEvenNumber(new int[]{1,2,4,6,8,4,100,200}); it.next(); it.next(); boolean result = it.hasNext(); Assert.assertThat(result,is(true)); }