[QUICK QUESTION] Random numbers and outcomes

I have the following code selecting a random type of terrain to generate:

	
        public int type = 0;
	Random rand = new Random();
        type = rand.nextInt(3);

What are all the possible outcomes?
0,1,2 ?
1,2,3 ?
0,1,2,3 ?

From JavaDoc:

[quote]Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator’s sequence.
[/quote]
So 0…2

so 0 is included and the number in the brackets isnt’?

correct

Why didn’t you just test out your code? Seriously, its as simple as throwing that code into a main method and printing out the result.

Everything in programming is 0 based (well some of it), so of course the “number in the brackets” won’t be included.

nextInt(int n)
Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator’s sequence.

-Taken from the javadoc

j.