Java Vector removeRange() MethodThe removeRange() method of Java Vector class is used to delete all elements from the vector whose index is between fromIndex, inclusive and toIndex, exclusive. The removal of elements shifts any succeeding elements to the left (reduces their index). SyntaxFollowing is the declaration of removeRange() method: Parameter
ReturnThis method does not return anything. It only removed the specified range of an element from the vector. ExceptionsIndexOutOfBoundsException- This method has thrown an exception if the index of an array is out of range i.e. (index < 0 || index >= size()). Compatibility VersionJava 1.2 and above Example 1Test it NowOutput: Vector element before removal: [9, 8, 7, 6, 5] Vector element after removal: [9, 6, 5] Example 2Test it NowOutput: Vector elements: [w, e, l, l, d, c, o, m, e] Vector elements after removal: [w, e, l, c, o, m, e] Next TopicJava Vector Setelementat Method |
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