I'm trying to figure out why my code isn't outputting the coin change permutations list as a list of int arrays. It's outputting some hex value (or whatever I@64578ceb
is).
Any thoughts?
Call:
System.out.println("Permutations List: " + dan.makeChange(27));
Code:
public class Person {
int[] denominations, coinValues;
List<int[]> resultsList;
public Person() {
denominations = new int[]{25, 10, 5, 1};
resultsList = new ArrayList<int[]>();
}
public List<int[]> makeChange(int change) {
return resultsList= changeMaker(change, new int[] {0,0,0,0});
}
public List<int[]> changeMaker(int change, int[] toAdd) {
if (change == 0) {
resultsList.add(toAdd);
return resultsList;
}
for (int i = 0; i < denominations.length; i++) {
if (change >= denominations[i]) {
int[] temp = toAdd;
temp[i]++;
resultsList = changeMaker(change-denominations[i], temp);
}
}
return resultsList;
}
Output:
Permutations List: [[I@64578ceb, [I@64578ceb, [I@64578ceb, [I@64578ceb, [I@64578ceb, [I@64578ceb, etc...
>`.
– Evan Mulawski May 13 '13 at 19:11>`.
– Matt Ball May 13 '13 at 19:12