+ 1
What is Random rand=new Random (); ?
Demonstrate with program
8 Respostas
+ 7
java.util.Random rand=new java.util.Random();
for(int i=999;i--!=0;)System.out.println(rand.nextInt(100));
//It is more efficient random and faster more than Math.random() This is my short answer
//And yeah Math.random() equivalent to rand.nextDouble()
+ 2
random number out which is integer?
+ 2
Yash, your code will output a random integer between 1 to 6 each time, right?
0
what is Random integers
- 1
import java.util.Random;
public class random
{
public static void main (String args[])
{
Random rand=new Random();
//This creates a rand object of class Random.
int a=rand.nextInt();
//Assigns a random integer to variable a.
System.out.println(a);
}
}
//This code will output a random integer each time.
//Hope I helped.