Java Spliterator estimateSize() MethodThe estimateSize() method of Java Interface Spliterator is used to get an estimate of the number of elements remaining to iterate or returns Long.MAX_VALUE if infinite, unknown, or too expensive to compute. SyntaxFollowing is the declaration of estimateSize() method- ParameterThis method does not accept any parameter. ReturnThe estimateSize() method returns the estimated size of elements or Long.MAX_VALUE if infinite, unknown, or too expensive to compute. ExceptionsNA Compatibility VersionJava 1.8 and above Example 1Test it NowOutput: Estimate size of ArrayList: 4 Elements of arraylist: 1 -2 3 -4 Example 2Test it NowOutput: Estimate size of List: 7 Example 3Test it NowOutput: Estimate size: 3 Name present in List: Rahul Rohit Surya Again Estimate size is: 0
Next TopicJava Spliterator class
|