title: Permutation of array
body: <p>For example I have this array:</p>
  
  <pre><code>int a[] = new int[]{3,4,6,2,1};
  </code></pre>
  
  <p>I need list of all permutations such that  if one is like this, <code>{3,2,1,4,6}</code>, others must not be the same. I know that if the length of the array is <em>n</em> then there are <em>n!</em> possible combinations. How can this algorithm be written?</p>
  
  <p>Update: thanks, but I need a pseudo code algorithm like:</p>
  
  <pre><code>for(int i=0;i&lt;a.length;i++){
      // code here
  }
  </code></pre>
  
  <p>Just algorithm. Yes, API functions are good, but it does not help me too much.</p>