1import java.util.Random;
2
3public static float randFloat(float min, float max) {
4
5 Random rand = new Random();
6
7 return rand.nextFloat() * (max - min) + min;
8
9}
10
1import java.util.Random;
2public class Example {
3 public static void main(String[] args) {
4 Random rd = new Random(); // creating Random object
5 System.out.println(rd.nextFloat()); // displaying a random float value between 0.0 and 1.0
6 }
7}
1Random r = new Random();
2double random = min + r.nextDouble() * (max - min);
3