Java ArrayList removeRange() methodThe removeRange() method of Java ArrayList class removes all elements whose index lies between fromIndex -inclusive- and toIndex -exclusive, shifts an elements to the left and reduce their index. If (fromIndex == toIndex) nothing will happen. Syntax:Parameter:fromIndex: is the index of element to be removed. toIndex: is the index after last the element to be removed. Return:Nothing. Exception:java.lang.IndexOutOfBoundsException: If fromIndex or toIndex is out of range. Example 1Test it NowOutput: [A, B, C, D] [A, D] [A, D, X, Y, Z] [X, Y, Z] Example 2Test it NowOutput: [A, B, C, D] Next TopicJava ArrayList |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India