The first element of the resulting stream is returned (1 operation).Each number is checked for divisibility (100 operations).Each number is doubled (100 operations).The range of numbers from 100 to 199 is created (100 operations).If we use for loop we will wasted lots of operations OptionalInt firstEvenIntegerDivB圓 = IntStream.range(100, 200) First integer between 200 and 400 divisible by 3 LongStream.rangeClosed(long startInclusive, long endInclusive)įor example, consider taking a range of numbers between 100 and 200, doubling each of them, and then finding the first the value that is evenly divisible by three, as inĮxample. LongStream.range(long startInclusive, long endExclusive) IntStream.rangeClosed(int startInclusive, int endInclusive) IntStream.range(int startInclusive, int endExclusive)
0 Comments
Leave a Reply. |