import java.util.ArrayList;
import java.util.Collections;
public class Program {
public static void main(String[] args) {
// Create an ArrayList of 4 elements.
ArrayList<Integer> array = new ArrayList<>();
array.add(1);
array.add(2);
array.add(3);
array.add(4);
System.out.println(
"BEFORE: " + array.toString());
// Shuffle elements.
Collections.shuffle(array);
System.out.println(
"AFTER 1: " + array.toString());
// Shuffle elements again.
Collections.shuffle(array);
System.out.println(
"AFTER 2: " + array.toString());
}
}
BEFORE: [1, 2, 3, 4]
AFTER 1: [3, 2, 4, 1]
AFTER 2: [4, 1, 3, 2]