| 6 | import java.util.stream.*; |
| 7 | |
| 8 | public class RandomGenerators { |
| 9 | public static <T> void show(Stream<T> stream) { |
| 10 | stream |
| 11 | .limit(4) |
| 12 | .forEach(System.out::println); |
| 13 | System.out.println("++++++++"); |
| 14 | } |
| 15 | public static void main(String[] args) { |
| 16 | Random rand = new Random(47); |
| 17 | show(rand.ints().boxed()); |
| 18 | show(rand.longs().boxed()); |
| 19 | show(rand.doubles().boxed()); |
| 20 | // Control the lower and upper bounds: |
| 21 | show(rand.ints(10, 20).boxed()); |
| 22 | show(rand.longs(50, 100).boxed()); |
| 23 | show(rand.doubles(20, 30).boxed()); |
| 24 | // Control the stream size: |
| 25 | show(rand.ints(2).boxed()); |
| 26 | show(rand.longs(2).boxed()); |
| 27 | show(rand.doubles(2).boxed()); |
| 28 | // Control the stream size and bounds: |
| 29 | show(rand.ints(3, 3, 9).boxed()); |
| 30 | show(rand.longs(3, 12, 22).boxed()); |
| 31 | show(rand.doubles(3, 11.5, 12.3).boxed()); |
| 32 | } |
| 33 | } |
| 34 | /* Output: |
| 35 | -1172028779 |
| 36 | 1717241110 |
nothing calls this directly
no outgoing calls
no test coverage detected