shuffle java code example
Example 1: 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 2: random java
import java.util.Random();
Random <name> = new Random();
<variable> = <name>.nextInt(<excuslive top limit>);