Introduction
Spliterator stands for Splitable Iterator. It is newly introduced by Oracle Corporation as part Java SE 8. Like Iterator and ListIterator, It is also one of the Iterator interface.
S.No. |
Spliterator |
Iterator |
1. |
It is introduced in Java SE 8. |
It is available since Java 1.2. |
2. |
Splitable Iterator |
Non-Splitable Iterator |
3. |
It is used for both Collection and Stream APIs. |
It is used for Collection API. |
4. |
It uses Internal Iteration concept to iterate Streams. |
It uses External Iteration concept to iterate Collections. |
5. |
We can use Spliterator to iterate Streams in Parallel and Sequential order. |
We can use Spliterator to iterate Collections only in Sequential order. |
6. |
We can get Spliterator by calling spliterator() method on Stream Object. |
We can get Iterator by calling iterator() method on Collection Object. |
7. |
Important Method: tryAdvance() |
Important Methods: next(), hasNext() |
That’s it about Java 8 Spliterator.
If you want to learn more Java SE Interview Questions, Please access my previous posts:
http://www.journaldev.com/8697/javase8-interview-questions-part1
http://www.journaldev.com/10081/javase8-interview-questions-part2
Please drop me a comment if you like my post or have any issues/suggestions.
No comments:
Post a Comment