The (int) actually goes with the next portion of code: it casts the result of ((Math.random () * (3))) to an integer. (This will simply drop the decimal portion; it will not round).
Math.random() returns a number that is greater than or equal to 0.0 and less than 1.0.
((Math.random () * (3))) simply returns a double that is greater than or equal to 0.0 and less than 3.0, which will, as I just mentioned, subsequently be cast to an int. (This will result in a number between 0 and 2; 3 isn’t possible).
Adding -1 to something is equivalent to subtracting 1.
So, this will result in a random integer between -1 and 1 (inclusive).
0
solved What does -1+ (int) mean?