1import java.util.ArrayList;
2import java.util.Spliterator;
3public class ArrayListSpliteratorMethodExample
4{
5 public static void main(String[] args)
6 {
7 ArrayList<String> al = new ArrayList<String>();
8 al.add("red");
9 al.add("blue");
10 al.add("green");
11 al.add("yellow");
12 al.add("orange");
13 // creating Spliterator of ArrayList and using spliterator() method
14 Spliterator<String> iterate = al.spliterator();
15 System.out.println("ArrayList of colors: ");
16 // forEachRemaining method of Spliterator
17 iterate.forEachRemaining((n) -> System.out.println(n));
18 }
19}