Interface CharIterator

All Superinterfaces:
Iterator<Character>, PrimitiveIterator<Character, CharConsumer>
All Known Subinterfaces:
CharBidirectionalIterator, CharBigListIterator, CharListIterator
All Known Implementing Classes:
AbstractCharBidirectionalIterator, AbstractCharBigListIterator, AbstractCharIterator, AbstractCharListIterator, CharBigListIterators.AbstractIndexBasedBigIterator, CharBigListIterators.AbstractIndexBasedBigListIterator, CharBigListIterators.BigListIteratorListIterator, CharBigListIterators.EmptyBigListIterator, CharBigListIterators.UnmodifiableBigListIterator, CharIterators.AbstractIndexBasedIterator, CharIterators.AbstractIndexBasedListIterator, CharIterators.EmptyIterator, CharIterators.UnmodifiableBidirectionalIterator, CharIterators.UnmodifiableIterator, CharIterators.UnmodifiableListIterator

public interface CharIterator extends PrimitiveIterator<Character, CharConsumer>
A type-specific Iterator; provides an additional method to avoid (un)boxing, and the possibility to skip elements.
See Also:
  • Method Details

    • nextChar

      char nextChar()
      Returns the next element as a primitive type.
      Returns:
      the next element in the iteration.
      See Also:
    • next

      @Deprecated default Character next()
      Deprecated.
      Please use the corresponding type-specific method instead.
      Specified by:
      next in interface Iterator<Character>
    • forEachRemaining

      default void forEachRemaining(CharConsumer action)
      Performs the given action for each remaining element until all elements have been processed or the action throws an exception.
      Specified by:
      forEachRemaining in interface PrimitiveIterator<Character, CharConsumer>
      Parameters:
      action - the action to be performed for each element.
      Since:
      8.0.0
      See Also:
      API Notes:
      Implementing classes should generally override this method, and take the default implementation of the other overloads which will delegate to this method (after proper conversions).
    • forEachRemaining

      default void forEachRemaining(IntConsumer action)
      Performs the given action for each remaining element, performing widening primitive casts, until all elements have been processed or the action throws an exception.
      Parameters:
      action - the action to be performed for each element.
      Since:
      8.5.0
      See Also:
      Implementation Notes:
      Unless the argument is type-specific, this method will introduce an intermediary lambda to perform widening casts. Please use the type-specific overload to avoid this overhead.
    • forEachRemaining

      @Deprecated default void forEachRemaining(Consumer<? super Character> action)
      Deprecated.
      Please use the corresponding type-specific method instead.
      Specified by:
      forEachRemaining in interface Iterator<Character>
    • skip

      default int skip(int n)
      Skips the given number of elements.

      The effect of this call is exactly the same as that of calling next() for n times (possibly stopping if Iterator.hasNext() becomes false).

      Parameters:
      n - the number of elements to skip.
      Returns:
      the number of elements actually skipped.
      See Also: