How to generate N random integers in Java

1 Answer

0 votes
import java.util.Random;
  
public class MyClass
{
    public static void main(String[] args)
    {
        Random random = new Random();

		int N = 10;

		random.ints(N).forEach(System.out::println);
    }
}
 
 
 
 
 
/*
run:
 
-1611068455
-810926332
-213864813
1886277981
1723906059
1074923018
1790635122
-1732129395
1415503834
-101880623
 
*/

 



answered Mar 18, 2023 by avibootz
...