Java Vector removeRange() Method | Rookie Tutorial
Rookie Tutorial --
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
Java Tutorial
Java TutorialJava IntroductionJava Environment SetupJava Basic SyntaxJava CommentsJava Objects and ClassesJava Basic Data TypesJava Variable TypesJava Variable Naming RulesJava ModifiersJava OperatorsJava Loop StructureJava Conditional StatementsJava switch caseJava Number & Math ClassJava Character ClassJava String ClassJava StringBufferJava ArrayJava Date and TimeJava Regular ExpressionsJava MethodsJava ConstructorJava Stream, File, IOJava Scanner ClassJava Exception Handling
Java Object-Oriented
Java InheritanceJava Override/OverloadJava PolymorphismJava Abstract ClassJava EncapsulationJava InterfaceJava EnumJava PackageJava Reflection
Java Advanced Tutorial
Java Data StructuresJava Collections FrameworkJava ArrayListJava LinkedListJava HashSetJava HashMapJava IteratorJava ObjectJava NIO FilesJava GenericsJava SerializationJava NetworkingJava Sending EmailJava MultithreadingJava Applet BasicsJava DocumentationJava ExamplesJava 8 New FeaturesJava MySQL ConnectionJava 9 New FeaturesJava QuizJava Common Libraries
Java Vector removeElementAt() Method
In-depth Exploration
Software
Programming Languages
Computer Science
Development Tools
Scripts
Scripting Languages
Web Design and Development
Web Service
Network Services
Programming
Java Vector removeRange() Method
The removeRange() method is a protected method provided by the Vector class in Java, used to remove all elements within a specified range from the Vector. This method is defined in the java.util.Vector class, inherited from the java.util.AbstractList class.
Syntax
protected void removeRange(int fromIndex, int toIndex)
Parameters
removeRange() method is a protected method provided by the Vector class in Java, used to remove all elements within a specified range from the Vector. This method is defined in the java.util.Vector class, inherited from the java.util.AbstractList class.protected void removeRange(int fromIndex, int toIndex)| Parameter Name | Type | Description |
|---|---|---|
| fromIndex | int | The index of the first element to be removed (inclusive) |
| toIndex | int | The index after the last element to be removed (exclusive) |
Method Characteristics
- Range Removal: Can remove multiple elements in a continuous range at once
- Index Boundaries:
fromIndexmust be less than or equal totoIndex- Both indexes must be within the valid range of the Vector (0 β€ fromIndex β€ toIndex β€ size())
- Performance Impact: After removing elements, all subsequent elements' indexes will shift forward accordingly
- Protected Method: Can only be called directly in subclasses of
Vector, or through reflection mechanism
Usage Example
Example
import java.util.Vector;
public class CustomVector<E>ext
YouTip