Getting random numbers in Java [duplicate]

I would like to get a random value between 1 to 50 in Java.

How may I do that with the help of Math.random();?

How do I bound the values that Math.random() returns?

2 s
2

Leave a Comment