This example will generate a set of random numbers within a given range using java and java 8 techniques.
Straight up Java
The code snippet below will generate 10 random numbers by using a for loop and calling random.nextInt.
Output
Java 8
Using Java 8 Stream api we will call Random.ints while specifing a range between 1 and 10.
Output