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