Question: Write a method called stretch that takes an integer as a parameter and that increases a list of integers by a factor of by replacing

Write a method called stretch that takes an integer as a parameter and that increases a list of integers by a factor of by replacing each integer in the original list with copies of that integer. For example, if a variable called list stores [18, 7, 4, 24, 11] and we make the call of list.stretch(3); the list should be changed to store [18, 18, 18, 7, 7, 7, 4, 4, 4, 24, 24, 24, 11, 11, 11] . If is zero or negative, the list should become empty.

Step by Step Solution

3.25 Rating (169 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public v... View full answer

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 Building Java Programs A Back to Basics Approach Questions!