Java Spliterator trySplit() MethodThe trySplit() method of Java Interface Spliterator is used to split the invoking spliterator. If this spliterator can be partitioned, returns a reference to a new spliterator for the partition, otherwise, it returns null. SyntaxFollowing is the declaration of trySplit() method- ParameterThis method does not accept any parameter. ReturnThe trySplit() method returns a spliterator covering some portion of the elements or returns null if this spliterator cannot be split. ExceptionsNA Compatibility VersionJava 1.8 and above Example 1Test it NowOutput: MySQL Python --Traversing the other half of the spliterator--- Java Android Example 2Test it NowOutput: Elements of ArrayList: 101 201 301 401 501 Output from splitr2: 101 201 Output from splitr1: 301 401 501
Next TopicJava Spliterator class
|