I look everywhere and cannot find an answer or a hint to my problem. I'm sure it has probably something to do with arrays being passed by reference and me having to possibly copy the elements and pass them to my instance variable, but I just can't figure it out.
to just keep things simple We create Wallet class that represents a wallet that can hold up to 10 bills. We are specifically told to not use Array Lists and to work with arrays. Wallet has two instance variables, but the only one I have problems on is this one
private int contents[ ];
my main is creating new Wallet object by the following calls
int a[ ] = {100, 50, 20, 1};
Wallet myWallet = new Wallet(a);
in my constructor, I have to allocate memory for the contents[ ] instance variable and then grab the elements from a[] and have them inside of the contents array.
public Wallet(int a [ ])
System.out.println("Constructor #2 called.");
//allocate memory for contents[]
contents = new int[MAX] //supposed to be of size 10, given info
//initialize contents[] from a[]
stuck here, how to I assign them to each other?
how do I copy 100,50,20,1 to contents at i = 0 - 3, and have reset of elements = 0?