Created
August 17, 2020 17:56
-
-
Save a2ankitrai/a2e86625ba5e6929a92a584532a7ba42 to your computer and use it in GitHub Desktop.
Generate stream for odd numbers less than 100
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.stream.Stream; | |
class StreamOddNumberUnder100 { | |
public static void main(String[] args) { | |
Stream<Integer> oddNumberUnder100 = | |
Stream.iterate(1, | |
i -> i < 100, | |
i -> i+2 | |
); | |
oddNumberUnder100.forEach(System.out::println); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment