SingletonPrimitiveIteratorOfInt implements PrimitiveIterator.OfInt { @Override public void forEachRemaining(IntConsumer action) { requireNonNull(action); if (hasNext) { action.accept(element); hasNext = false; } } SingletonPrimitiveIteratorOfInt(int e); @Override boolean hasNext(); @Override int nextInt(); @Override Integer next(); @Override void remove(); @Override void forEachRemaining(IntConsumer action);  }
@Test void forEachRemainingIntConsumer() { instance.forEachRemaining((IntConsumer)i -> cnt.incrementAndGet()); assertEquals(1, cnt.get()); }
@Test void forEachRemainingConsumer() { instance.forEachRemaining((Consumer<Integer>) i -> cnt.incrementAndGet()); assertEquals(1, cnt.get()); }