Random.nextFloat is not applicable for floats?

前端 未结 4 2306
清酒与你
清酒与你 2021-02-13 02:02
float minX = 50.0f;
float maxX = 100.0f;

Random rand = new Random();

float finalX = rand.nextFloat(maxX - minX + 1.0f) + minX;

\"The method nextFloat

4条回答
  •  后悔当初
    2021-02-13 02:21

    It should read like the following as others are suggesting.

    float finalX = rand.nextFloat();
    // do other stuff
    

提交回复
热议问题