question: public static int [ ] randomPermutation ( final int [ ] out , Random random ) { for ( int i = out . length - 1 ; i > 0 ; i -- ) { int ri = random . nextInt ( i + 1 ) ; int tmp = out [ ri ] ; out [ ri ] = out [ i ] ; out [ i ] = tmp ; } return out ; }
target:  Perform a random permutation of the array, in-place. Knuth / Fisher-Yates style shuffle