As the documentation says, this method call returns “a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive)”. This means that you will get numbers from 0 to 9 in your case. So you’ve done everything correctly by adding one to that number.
Generally speaking, if you need to generate numbers from min
to max
(including both), you write
random.nextInt(max - min + 1) + min