random Float - Android java.util

Android examples for java.util:Random Double

Description

random Float

Demo Code


import java.util.Random;
import android.os.SystemClock;

public class Main{
    private static final Random mRandom;
    public static float randomFloat(float maximum) {
        return mRandom.nextFloat() * maximum;
    }//  ww  w.j a va 2  s . c  o  m
    public static float randomFloat(float minimum, float maximum) {
        return randomFloat(maximum - minimum) + minimum;
    }
}

Related Tutorials