IntStream distinct() in Java with examples
IntStream distinct() is a method in java.util.stream.IntStream. This method returns a stream consisting of the distinct elements. This is a stateful intermediate operation i.e, it may incorporate state from previously seen elements when processing new elements.
IntStream distinct() Where, IntStream is a sequence of primitive int-valued elements.
Below given are some examples to understand the function in a better way.
Example 1 : Printing distinct elements of Integer stream.
2 3 5 6 8
Example 2 : Counting value of distinct elements in a stream.
My Personal Notes arrow_drop_up
Please Login to comment...