BAEL-669 test of an infinite stream (#1126)

* BAEL-669 test of an infinite stream

* BAEL-699 example of custom type infinite stream

* BAEL-699 do..while stream way

* BAEL-669 generate stream of random uuids
This commit is contained in:
Tomasz Lelek
2017-02-12 10:22:25 +01:00
committed by Grzegorz Piwowarek
parent 4aaefd39df
commit f772286896
2 changed files with 75 additions and 0 deletions
@@ -0,0 +1,27 @@
package com.baeldung.stream;
import java.util.stream.Stream;
public class InfiniteStreams {
public static void main(String[] args) {
doWhileOldWay();
doWhileStreamWay();
}
private static void doWhileOldWay() {
int i = 0;
while (i < 10) {
System.out.println(i);
i++;
}
}
private static void doWhileStreamWay() {
Stream<Integer> integers = Stream.iterate(0, i -> i + 1);
integers.limit(10).forEach(System.out::println);
}
}