Java Math random integer in a range
public class Main { public static void main(String[] args) { System.out.println(randomMinMax(5, 10)); System.out.println(randomMinMax(5, 10)); System.out.println(randomMinMax(5, 10)); System.out.println(randomMinMax(5, 10)); System.out.println(randomMinMax(5, 10)); System.out.println(randomMinMax(5, 10)); System.out.println(randomMinMax(5, 10)); System.out.println(randomMinMax(5, 10)); System.out.println(randomMinMax(5, 10)); System.out.println(randomMinMax(5, 10)); }/*from ww w. j a v a2 s . c om*/ public static int randomMinMax(int min, int max) { return (int) (Math.random() * ((max - min) + 1)) + min; } }