Question: Java: Copying array the exact number of times to the end of the data array public void copy(int howmany) { //This code lives inside an
Java: Copying array the exact number of times to the end of the data array
public void copy(int howmany) { //This code lives inside an RArrayList, so you have access to data[] array, data.capacity, and the size variable.
// Calculate the new capacity to determine if there's enough room and expand if there is not.
int newcapacity = size * howmany; if (newcapacity > data.length)
expandToCapacity(newcapacity);
// WRITE YOUR CODE HERE: Copy the existing data in the array the correct number of times to the end of the data array and then update size variable.
Also: assume howmany is an int >1. The code you are writing should copy and append (no other functions)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
