Get a random numberTag(s): String/Number


JDK1.1, Random.nextInt() returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence.
// random number between 0 AND 10
import java.util.Random;

Random r = new Random();
int randint = Math.abs(r.nextInt()) % 11;
JDK1.2, Random.nextInt(n) returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and n (exclusive).
// random number between 0 AND 10
import java.util.Random;

Random r = new Random();
int randint = r.nextInt(10);

blog comments powered by Disqus