Print multiple of 3 up to 30 in java 8 using Stream API

Display the multiple of any number in java 8 using stream API, Here is the example of multiple of 3 up to 30 and print them.

IntStream.iterate(1, i->i+1).map(i->i*3).limit(100).forEach(System.out::println);


Output:
3
6
9
12
15
18
21
24
27
30

Happy Coding !!!

0 comments:

Post a Comment