Random array Java code example
Example 1: random number python
# generate random integer values
from random import randint
value = randint(0, 10)
print(value)
Example 2: how to randomize an array java
void shuffle(int [] arr) {
for (int i = 0; i < arr.length; i++) {
int index = (int) (Math.random() * arr.length);
int temp = arr[i];
arr[i] = arr[index];
arr[index] = temp;
}
}
Example 3: generate random integer javascript
var randomnumber = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
Example 4: get raondom from array java
public static int getRandom(int[] array) {
int rnd = new Random().nextInt(array.length);
return array[rnd];
}