http://docs.oracle.com/javase/6/docs/api/java/util/Random.html#nextInt%28int%29 says:
The algorithm is slightly tricky. It rejects values that would r
2^31 is only divisibale by a power or 2. When you check the code, this special case is treated separately without a loop. The Description is related to the rejecting-process, and there n is not a power of 2.