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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!