How to shuffle an ArrayList [duplicate]

Use this method and pass your array in parameter

Collections.shuffle(arrayList);

This method return void so it will not give you a new list but as we know that array is passed as a reference type in Java so it will shuffle your array and save shuffled values in it. That's why you don't need any return type.

You can now use arraylist which is shuffled.


Try Collections.shuffle(list).If usage of this method is barred for solving the problem, then one can look at the actual implementation.