To my knowledge, they both do the same thing, which is generate a value between 0.0 and 1.0, right?
Asked
Active
Viewed 1,385 times
-1
-
2yes, -- except one returns a double, and one returns a float... – Ilan Keshet Jun 24 '18 at 20:19
-
`double`is to `float` as `long` is to `int`. Not really sure what the question is here - you seem to have answered it yourself. – Boris the Spider Jun 24 '18 at 20:42
-
P.S. presumably you think `nextBoolean` is the same too? – Boris the Spider Jun 24 '18 at 20:42
1 Answers
1
One return a float, one return a double.
Just try this:
Random random = new Random();
System.out.println("nextFloat: " + random.nextFloat() + ", nextDouble: " + random.nextDouble());
that returns: nextFloat: 0.9613963, nextDouble: 0.9364254125546306

Altoz 123
- 11
- 2