What are the differences between Iterator and Spliterator in Java 8?

Main differences between Iterator and Spliterator are as follows:

  • Spliterator can be used with Streams in Java 8. Where as, Iterator is just used with Collection.
  • Spliterator uses Internal Iteration to iterate Streams. Iterator uses External Iteration to iterate Collections.
  • Spliterator can iterate Streams in Parallel as well as Sequential manner. Iterator only iterates in Sequential manner.
  • Spliterator can traverse elements individually as well as in bulk. Iterator only iterates elements individually.

Leave a Reply

Your email address will not be published. Required fields are marked *