+ 1
How the Random number is generated in Java using Random class ?
Logic behind the process of generating random numbers
2 Respostas
+ 20
import java.util.Random;
public class Program
{
public static void main(String[] args) {
Random rand = new Random();
int value = rand.nextInt(50);
System.out.println(value) ;
}
}
java.util.Random class
👆is the built-in method in Java to generate random number...
not truly random but uniformly distributed based on mathematical functions... good enough in most cases
the argument 50 passed provide the upper bound limit...
check this out for more 👇
https://www.geeksforgeeks.org/generating-random-numbers-in-java/