Take the random number of the specified range
This is a very practical function. It is just to strengthen memory here, just remember that a formula is OK. Such as minimum min, maximum max, random number R ≤ Max in min ≤ r ≤ Max, formula is as follows: (int) ((Max - min 1) * Math.random ()) min I understand that there is nothing to say. The implementation code is as follows: / * * Create a date 2004-12-11 * * / / ** * Take the random number of specified range * * @Author wubai * * / public class getrandom {/ ** * Take the random number of specified range * * @Param min start range * @Param max End range * @return random number * / public int GETRANDOM (INT min, int max) {RETURN (INT) * Math.random ()) Min;} // Test public static void main (string [] args) {getrandom test = new getrandom (); int random = test.getrandom (10, 99); System.out.Println ("Random IS" Random }}