ArraySpliterator implements Spliterator<T> { @SuppressWarnings("unchecked") @Override public void forEachRemaining(Consumer<? super T> action) { requireNonNull(action); int i; int hi; if (array.length >= (hi = size) && (i = index) >= 0 && i < (index = hi)) { do { action.accept((T) array[i]); } while (++i < hi); } } ArraySpliterator(Object[] array, int additionalCharacteristics);   ArraySpliterator(Object[] array, int origin, int size, int additionalCharacteristics); @Override Spliterator<T> trySplit(); @SuppressWarnings("unchecked") @Override void forEachRemaining(Consumer<? super T> action); @Override boolean tryAdvance(Consumer<? super T> action); @Override long estimateSize(); @Override int characteristics(); @Override Comparator<? super T> getComparator();  }
@Test void testForEachRemaining() { final Set<Integer> set = new HashSet<>(); assertTrue(instance.tryAdvance(set::add)); instance.forEachRemaining(set::add); assertEquals(expectedSet, set); }