Question: Write a method that takes 2 parameters: an ArrayList list, and an int numRepeats representing the number of times to repeat each element in the
Write a method that takes parameters: an ArrayList list, and an int numRepeats representing the number of times to repeat each element in the array.
Return a new ArrayList with each element repeated numRepeats times.
For example, if we had an ArrayList list with the values helloworld:
repeatElementslist
Should return a new ArrayList with the elements:
hello "hello", "hello", "world", "world", "world"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
