I need to generate a random number between 0 and 2 using Math.random but it keeps giving me a 2

I need to generate a random number between 0 and 2 using Math.random but it keeps giving me a 2
0

#1

Tell us what’s happening:

I used
int randNumber = (int)(Math.random() *3);

It keeps choosing the 2


#2

Can you post your entire code?