- because random () returns double values greater than or equal to 0.0 and lesser than 1.0. So when you take the ( int ) part of Math.random () * 10, it will always lesser than or equal to 9 (even 9.9 would be converted to 9, that way).