I need some help in debugging the following java program.

```
import java.util.Random;

public class NextInt
{
    public static void main(String[] args)
    {
        for(int i=0; i<20; ++i)
        {
            if(i>0)
                System.out.print(", ");
            int x = (new Random()).nextInt();
            System.out.print( x % 2 + 1);
        }
        System.out.println("");
    }
}

```

Will output (for example):

```
0, 1, 0, 1, 2, 2, 2, 0, 0, 1, 1, 1, 2, 0, 1, 1, 1, 1, 2, 1

```

I think the output should have been containing only ones and twos! If we think about the `x % (2+1)` interpretation then the output is correct. Is the modulo operator really weaker than the addition? [Java tutorial](http://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html) says no. Or is there something else that I am missing?