Question: Write a method called removeRange that accepts a starting and ending index as parameters and removes the elements at those indexes (inclusive) from the list.
Write a method called removeRange that accepts a starting and ending index as parameters and removes the elements at those indexes (inclusive) from the list. For example, if a variable list stores the values [8, 13, 17, 4, 9, 12, 98, 41, 7, 23, 0, 92], the call of listRange.removeRange(3, 8); should remove values between index 3 and index 8 (the values 4 and 7 ), leaving the list of [8, 13, 17, 23, 0, 92]. The method should throw an IllegalArgumentException if either of the positions is negative. Otherwise you may assume that the positions represent a legal range of the list (0 ≤ and ≤ end < size).
Step by Step Solution
3.44 Rating (170 Votes )
There are 3 Steps involved in it
public void removeRange int low int high if low 0 high 0 ... View full answer
Get step-by-step solutions from verified subject matter experts
