Here you can find the source of randFloat(float min, float max)
Parameter | Description |
---|---|
min | Minimum value |
max | Maximum value. Must be greater than min |
public static float randFloat(float min, float max)
//package com.java2s; //License from project: Apache License import java.util.Random; public class Main { /**//from www .j a v a 2 s . c o m * Returns a pseudo-random number between min and max, inclusive * @param min Minimum value * @param max Maximum value. Must be greater than min * @return float between min and max, inclusive */ public static float randFloat(float min, float max) { Random rand = new Random(); return rand.nextFloat() * (max - min) + min; } }