0
What is the rondom class?
how can make ,what is the method and which method of rondom class is most applicatable??
4 Answers
+ 1
Well, mos languages have a Random element.
In Java we have the class Random and some methods inside it. To get a random value/number we can just use one of these methods such as:
Ā“Ā“Ā“
Random rndObj = new Random();
int randomNumber = rnd.nextInt();
Ā“Ā“Ā“
The random numbers are used to several approaches. For example, a simple use is get a random element from a array. Look:
Ā“Ā“Ā“
Random rndObj = new Random();
String[] colors = {"red", "green", "blue"};
System.out.println(colors[rndObj.nextInt(colors.length)]); //this should print a random color name from the array.
Ā“Ā“Ā“
There are others methods inside Random class, like nextBoolean, nextGaussian, and so on.
0
Did you mean... "random"?
0
yesšššš
0
tanx