title: How can i print all possible order of an array with n integers using recursion?
body: <p>For example, if I have an array a=  {1, 2, 6, 10}, it should print all combinations of these 4 numbers, there should be 4! total combinations. An array of 5 integers will have a total of 5! combinations. (Different from previous versions because my number of parameters have to stay same. I am not allowed to put more than 3 paramrters in.</p>
  
  <p>array a=  {1, 2, 6, 10}</p>
  
  <p>{1, 2, 10, 6}</p>
  
  <p>{1, 6, 2, 10}</p>
  
  <p>{1, 6, 10, 2}</p>
  
  <p>.</p>
  
  <p>.</p>
  
  <p>.</p>
  
  <p>{10, 6, 2, 1}</p>
  
  <p>I am trying to solve this process using Recursion, any idea how? this is the code i have for now. Can anyone who has any idea whats going on please help me?</p>
  
  <pre><code>static void permutations (int a[], int n, int p){
      if (p==n-1)
          return ;
      for (int i=p; i&lt;n; i++){
          int b[]=new int [n];
          b[p]=a[i];
          for (int j=0; j&lt;i; j++)
              b[j]=a[j];
              for (int k =i+1; k&lt;n; k++)
                  b[k]=a[k];    
          System.out.println(Arrays.toString(b));
          return permutations(b, n, p+1);  
      }         
  }
  </code></pre>