Javatpoint Logo
Javatpoint Logo

Java Random nextFloat() Method

The nextFloat() method of Random class returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from the random number generator's sequence.

Syntax

Parameters

NA

Return Value

The nextFloat() method returns the next pseudorandom float number between 0.0 and 1.0.

Example 1

Test it Now

Output:

Random Float value : 0.25081772
Random Float value : 0.52181274

Example 2

Test it Now

Output:

Enter number of students.5
Enter name of 5 students.
1 Payal
2 Anshu
3 Baby
4 Mona
5 Jugnoo
1. Payal's id  : 0.14586294
2. Anshu's id  : 0.78586906
3. Baby's id  : 0.76507455
4. Mona's id  : 0.9362442
5. Jugnoo's id  : 0.5890219
Next TopicJava Random




Help Others, Please Share

facebook twitter pinterest