w3resource

Java ArrayList.spliterator() Method

public Spliterator<E> spliterator()

The spliterator() method is used to create a late-binding and fail-fast Spliterator over the elements in this list.
The Spliterator reports Spliterator.SIZED, Spliterator.SUBSIZED, and Spliterator.ORDERED.

Package: java.util

Java Platform: Java SE 8

Syntax:

spliterator

Return Value:

A Spliterator over the elements in this list

Example: ArrayList.spliterator Method

import java.util.*;

public class test {
  public static void main(String[] args) {
 
  ArrayList<Integer> number_List;
  Spliterator<Integer> mySpliterator;

  number_List = new ArrayList<> ();
  
  number_List.add(1);
  number_List.add(2);
  number_List.add(3);
  number_List.add(4);
  
  mySpliterator = number_List.spliterator();
  
  System.out.println("Characteristics Of Spliterator are : "+mySpliterator.characteristics());
 }
}

Output:

F:\java>javac test.java

F:\java>java test
Characteristics Of Spliterator are : 16464

Previous:foreach Method
Next:removeIf



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/java-tutorial/arraylist/arraylist_spliterator.php