The Random variable. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

The Random variable.

Does the float "random" exist in Java? If it does, how do I have to use it?

12th Feb 2017, 3:48 PM
Vicente Alfaro
Vicente Alfaro - avatar
3 Answers
+ 2
This may help: Random randFloat = new Random(10); float num = randFloat.nextFloat(); Random randInt = new Random(10); int num1 = randInt.nextInt(); System.out.println(num); System.out.println(num1); When first run results were: 0.73043025 -1157793070
12th Feb 2017, 4:07 PM
Mike Allen
Mike Allen - avatar
+ 2
https://code.sololearn.com/ckcAXAaHfQI9/?ref=app Program which will generate some random numbers and sort them in descending order
13th Feb 2017, 2:50 PM
Kommoju Sunil Kumar
Kommoju Sunil Kumar - avatar
0
import java.util.Random Random rand = new Random();
12th Feb 2017, 4:00 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar