while loop random number Java

So in this post we try to do a simple loop that display some random Numbers. See example below:

while loop random number Java

So below is a simple example that uses while loop to generate 10 random numbers between 0 and 100.
import java.util.Random;
/**
 * An example program that generate 10 random numbers between 0 and 100.
 */
public class ExampleProgram {
    public static void main(String[] args) {
        Random rnd = new Random();
        int i = 0;
        while (i<10) {
            System.out.println(rnd.nextInt(100));
            i++;
        }
    }
}

And we get below output when we run this code:

31
60
20
67
77
77
81
17
55
21