java math.random
int rand = (int)(Math.random() * range) + min;
java math.random
int rand = (int)(Math.random() * range) + min;
maths.random in Java
double rand = (Math.random() * range) + min;
Generate Random number using Math.random in Java
class GenerateRandom {
public static void main( String args[] ) {
int min = 50;
int max = 100;
//Generate random int value from 50 to 100
System.out.println("Random value in int from "+min+" to "+max+ ":");
int random_int = (int)Math.floor(Math.random()*(max-min+1)+min);
System.out.println(random_int);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us