+ 1

What is Random rand=new Random (); ?

Demonstrate with program

3rd Sep 2017, 7:48 AM
Kartikey Gupta
Kartikey Gupta - avatar
5 Respuestas
+ 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()
3rd Sep 2017, 7:52 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 2
random number out which is integer?
5th Sep 2017, 11:51 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 2
Yash, your code will output a random integer between 1 to 6 each time, right?
6th Sep 2017, 1:26 AM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar
0
what is Random integers
5th Sep 2017, 5:52 PM
Kartikey Gupta
Kartikey Gupta - avatar
- 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.
3rd Sep 2017, 8:47 AM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar