How can I permute an int[] and save each int[] into an int[][]?
<p>This is in Java.</p>

<p>I need to permute the first row in the int[][] and save each resulting permutation in the subsequent rows.  My professor gave me this string version of the implementation as a guide:</p>

<pre><code>private static void permute( char [ ] str, int low, int high )
{
        if( low == high )
        System.out.println( str );
    for( int i = low; i &lt;= high; i++ )
    {
        char [ ] tmp = str.clone( ); // tmp will be str
        tmp[ i ] = str[ low ]; // with i and low
        tmp[ low ] = str[ i ]; // swapped
        permute( tmp, low + 1, high );
    }
}
</code></pre>

<p>Here's what I have so far (the first bit is how I'm calling it):</p>

<pre><code>for (int row = 0; row &lt; arr.length * LIST_SIZE; row++){
        if (arr.length % LIST_SIZE == LIST_SIZE-1)
            arr[row] = permute(arr[row%LIST_SIZE], 0, LIST_SIZE-1).clone();
    }

public int[] permute(int[] intArr, int low, int high){
    int[] returnArr = null;

    if (low == high){
        returnArr = intArr.clone();
    }

    for (int i = low; i &lt;= high; i++){
        int[] temp = intArr.clone();
        temp[i] = intArr[low];
        temp[low] = intArr[i];
        permute(temp, low+1, high);
    }

    return returnArr;
}
</code></pre>

<p>Right now, each row of the 2d array after the first is just filled with zeros. I have a feeling I'm making this significantly harder than it is.</p>
