public static void shuffle ( final int [ ] arr , final Random rng ) { // Fisher-Yates shuffle for ( int i = arr . length ; i > 1 ; i -- ) { // swap i-1 and a random spot final int a = i - 1 ; final int b = rng . nextInt ( i ) ; final int tmp = arr [ b ] ; arr [ b ] = arr [ a ] ; arr [ a ] = tmp ; } }
Fisher - Yates suffer a primitive int array