This is the IntArrayBag I'm talking about. For the sake of the question, here are the data fields and the constructor:
private int[ ] data;
private int manyItems;
public IntArrayBag( )
{
final int INITIAL_CAPACITY = 10;
manyItems = 0;
data = new int[INITIAL_CAPACITY];
}
My question is, how could I make this class generic so that this method would take any type of object as an argument (instead of an integer)? I was thinking about making the array generic but according to this answer arrays cannot be generic and this answer stating that you cannot have generic data fields.
How would one make this class generic then? Thank you!