Generating a random float between x and y

You can use the formula:

   lowerbound + ((upperbound - lowerbound) * randomfloat)

To get a random float number, instantiate a Random object and call the method nextFloat which returns a pseudo-random float between 0 and 1.

Main.java:

import java.util.*;
  
public class Main {   
   static Random r = new Random();
 
   public static void main(String[] args) throws Exception {
  
      for (int i=0; i<10; i++) 
         System.out.println(getRandomFloat(-10, 15));
   }
 
   public static float getRandomFloat(float min, float max) {
      return min + (r.nextFloat() * (max - min));
   }
}

outputs:

-5.6623406
1.2526817
-9.871614
-9.995427
-1.407754
0.7924614
-5.201227
-3.9035373
11.673981
3.3402395