Javatpoint Logo
Javatpoint Logo

Java Spliterator forEachRemaining() Method

The forEachRemaining() method of Java Interface Spliterator is used to performs the given action for each remaining element sequentially in the current thread until all elements have been processed or the action throws an exception.

Syntax

Following is the declaration of forEachRemaining() method-

Parameter

Parameter Description Required/Optional
action It is the action performs to check remaining elements. Required

Return

The forEachRemaining() method does not return anything. It only performs the given action for each remaining element.

Exceptions

NullPointerException- This method has thrown an exception if the specified action is null.

Compatibility Version

Java 1.8 and above

Example 1

Test it Now

Output:

Skype
Next Element Present? true
Remaining Name Present in the List:
Facebook
Instagram
Twitter

Example 2

Test it Now

Output:

Elements Exist in arraylist :
100
-200
300
-400
500

Example 3

Test it Now

Output:

Elements os Array-
1
2
3
4



Help Others, Please Share

facebook twitter pinterest