Java coin change outputting weird values [Not homework]
<p>I'm trying to get my coin change algorithm to work... but it's outputting weird results...
It's supposed to enumerate all permutations of change to be given for input amount of cents.</p>

<p>input of 27 cents, <code>printValues(dan.makeChange(27));</code>  gets me:</p>

<p><code>[[3, 300, 1386, 4720], [3, 300, 1386, 4720], [3, 300, 1386, 4720],etc...</code></p>

<p>input of 7 cents gets me:</p>

<p><code>[[0, 0, 3, 10], [0, 0, 3, 10], [0, 0, 3, 10], [0, 0, 3, 10]]</code></p>

<p><strong>Code:</strong></p>

<pre><code>public List&lt;int[]&gt; makeChange(int change) {
    List&lt;int[]&gt; resultsList = new ArrayList&lt;int[]&gt;();
    resultsList = changeMaker(change, new int[] {0,0,0,0}, resultsList);
    return resultsList;
}

public List&lt;int[]&gt; changeMaker(int change, int[] toAdd, List&lt;int[]&gt; resultsList) {               
    if (change == 0) {
        //if no $, return the list...
        resultsList.add(toAdd);
        return resultsList;
    }
    int[] coins = {25, 10, 5, 1};
    for (int i = 0; i &lt; coins.length; i++) {
        if (coins[i] &lt;= change) {
            //temp = {0, 0, 0, 0}
            int[] temp = toAdd;
            //move to next amount in temp array
            temp[i]++;
            resultsList = changeMaker(change-coins[i], temp, resultsList);
        }
    }
    return resultsList;
}
</code></pre>

<p>Call:</p>

<pre><code>    printValues(dan.makeChange(27));            
}
public void printValues (List&lt;int[]&gt; results) {
    List&lt;String&gt; printable = new ArrayList&lt;String&gt; ();

    for (int[] array : results) {
        printable.add(Arrays.toString(array));
    }
    System.out.println(printable);
}
</code></pre>

<p>Any thoughts? </p>
