title: How to generate a random permutation in Java?
body: <p>What is the best way to generate a random permutation of n numbers?</p>
  
  <p>For example, say I have a set of numbers 1, 2 and 3 (n = 3)</p>
  
  <p>Set of all possible permutations: {123, 132, 213, 231, 312, 321}</p>
  
  <p>Now, how do I generate:</p>
  
  <ul>
  <li>one of the elements of the above sets (randomly chosen)</li>
  <li>a whole permutation set as shown above</li>
  </ul>
  
  <p>In other words, if I have an array of n elements, how do I shuffle them randomly? Please assist. Thanks.</p>