M
M
Mark2014-02-14 16:46:40
Java
Mark, 2014-02-14 16:46:40

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

2 answer(s)
O
Oleg, 2014-02-14
@Aikoku

Put in an array, and randomize to the number of elements in the array.

A
AxisPod, 2014-02-14
@AxisPod

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 your question

Ask a Question

731 491 924 answers to any question