code: public static int[] randomPermutation(int size) {
          Random r = new Random();
          int[] result = new int[size];
  
          for (int j = 0; j < size; j++) {
              result[j] = j;
          }
          
          for (int j = size - 1; j > 0; j--) {
              int k = r.nextInt(j);
              int temp = result[j];
              result[j] = result[k];
              result[k] = temp;
          }
  
          return result;
      }
docs: Create a random permutation of the numbers 0, ..., size - 1.
  
  see Algorithm P, D.E. Knuth: The Art of Computer Programming, Vol. 2, p. 145