Categories
How to set correct Math.random conditions in Java for numbers from 0, 1, 3 or 5?
You need to make conditions for randomly calling one of the specified numbers: 0, 1, 3 or 5. Java language, you need to use Math.random
Answer the question
In order to leave comments, you need to log in
Put in an array, and randomize to the number of elements in the array.
In this case, of course, you can make 0..3 and, by condition, lead to the desired one, but of course, it’s easier and more visually an array.
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question