Trivial implementation of java.util.Random.nextInt(int n)

This commit is contained in:
Eric Scharff 2008-02-26 09:37:46 -07:00
parent e616161d5a
commit eaa8d5c64b

View File

@ -11,6 +11,10 @@
package java.util; package java.util;
public class Random { public class Random {
public int nextInt(int n) {
return nextInt() % n;
}
public int nextInt() { public int nextInt() {
return (int)(Math.random()*Integer.MAX_VALUE); return (int)(Math.random()*Integer.MAX_VALUE);
} }