There is an array in which there are 4 elements, how to randomly move these elements, for example, the first element became the third, the second fourth, and so on. And so every time in different ways.
1 answer
If you don’t think much about cryptographic stance then
Collections.shuffle(list); - 3From myself I will add that, taking into account the features of the
Arrays.asList(arr)method, you can mix the original arr [] array as follows:Collections.shuffle(Arrays.asList(arr))Attention! not suitable for arrays of primitive types (int [], etc.). - Nikolay Romanov - I would say that this is a feature of the Collections.shuffle () method - Oleksiy Morenets
|