See the following running code to print 20 random numbers in java 8.
package com.java8.array;
import java.util.Random;
public class PrintTwentyRandomNumber {
public static void main(String[] args) {
Random random = new Random();
random.ints().limit(20).forEach(System.out::println);
}
}
Output:-
741030149
1186911335
1855603872
559190233
-853992405
-329562563
-572666224
1894228184
504662856
-329826852
1542716680
1368337245
1220352397
-1534451523
1614911817
-1381109474
160656823
419145868
1557654430
-361011715