Using Math.random works when you need to generate a single random number. If you need a series of random numbers, you should create an instance of java.util.Random and invoke methods on that object to generate numbers. In Java 8, java.util.Random is enhanced to return an effectively unlimited stream by passing origin and bound parameters.