This works alright, but also keep in mind that the Random class has more methods that make code such as this unnecessary.

The method you illustrated above is <Random>.nextInt(int n), where n = 10...