Java HashSet spliterator() Method

The spliterator() method of Java HashSet class is used to creates a late-binding and fail-fast Spliterator over the elements in this set.

Syntax

Following is the declaration of spliterator() method:

Parameter

This method does not accept any parameter.

Returns

The spliterator() method returns a Spliterator over the elements in this set.

Exceptions

NA

Compatibility Version

1.8 and above

Example 1

Output:

Java
Android
JavaScript

Example 2

Output:

spliterator of HashSet is: 3

Example 3

Output:

Apple
--Bulk List traversal---
Banana
Orange
Graps
 --- Attempting tryAdvance again---
Element exists: false