You can use Collections.shuffle(List) to shuffle the array:
Integer[] data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; Collections.shuffle(Arrays.asList(data)); System.out.println(Arrays.toString(data));
will be printed, for example. [6, 2, 4, 5, 10, 3, 1, 8, 9, 7].
Arrays.asList will not create a new list, but a List interface wrapper for the array, so changes to the list will also be passed to the array.
source share