trying to initialize my array at 1 and have it double every time it’s input fills up. this is what i have right now
int max = 1;
PhoneRecord[] records = new PhoneRecord[max];
int numRecords = 0;
int size = Integer.parseInt(length.records[numRecords]);
if (size >= max) {
size = 2*size;
}
but it’s clearly full of fail. any suggestions or guidance would be great, thanks.
OK, you should use an
ArrayList, but several other folks already told you that.If you still want to use an array, here’s how you’d resize it: