How to generate random integers within a specific range in Java? I am trying to generate a random intvalue with Java, but in a specific range. For example: My range is 5-10, meaning that 5 is the smallest possible value and 10 is the biggest. Any other number in between these numbers is possible to be a value, too. In Java, there is a method random() in the Math class, which returns a double value between 0.0 and 1.0. In the class Random there is the method nextInt(int n), which returns a random intvalue in the range of 0 (inclusive) and n (exclusive). I couldn't find