# Can anyone Help me in understanding the below code snippet related to Java Stream?

**URL:** <https://forum.codewithmosh.com/t/can-anyone-help-me-in-understanding-the-below-code-snippet-related-to-java-stream/21510>\
**Category:** Java\
**Created:** [July 15, 2023, 6:32am UTC](https://forum.codewithmosh.com/t/can-anyone-help-me-in-understanding-the-below-code-snippet-related-to-java-stream/21510 "2023-07-15T06:32:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sanket007](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@Sanket007](https://forum.codewithmosh.com/u/Sanket007)\
**Post date:** [July 15, 2023, 6:32am UTC](https://forum.codewithmosh.com/t/can-anyone-help-me-in-understanding-the-below-code-snippet-related-to-java-stream/21510/1 "2023-07-15T06:32:52Z")

</div>

```auto
    public static IntStream primes(int max){
        IntStream primes = IntStream.range(2, max);
        IntFunction<IntPredicate> sieve = n->i->i==n || i % n != 0;
        primes = primes.filter(sieve.apply(2));
        for(int i = 3; i * i <= max; i++){
            primes = primes.filter(sieve.apply(i));
        }
        return primes;
    }

```

I am not able to understand How sieve and prime is calculated here ?The expression n-\>i-\>i==n || i % n != 0; I am not able to understand.
