I need to change the size of an array, but I cannot simply create another - It needs the same name so I can pass it to a method. Specifically, I need the array to have twice
I used the Arrays.copyOf method, like this:
int myArray[] = {1,2,3};
myArray = Arrays.copyOf(myArray, myArray.length+1);
//previous line creates a copy of the array and adds one to the size
myArray[3] = 12; // assign the new fourth element the value of 12
//then loop through the array to output each element
for(int ctr = 0; ctr