random.nextInt(max - min + 1) + min code example Example: random in java a to b Min + (int)(Math.random() * ((Max - Min) + 1))