Remove element from a vector
E remove(int index)
- Removes the element at the specified position in this Vector.
boolean remove(Object o)
- Removes the first occurrence of the specified element in this Vector If the Vector does not contain the element, it is unchanged.
boolean removeAll(Collection<?> c)
- Removes from this Vector all of its elements that are contained in the specified Collection.
void removeAllElements()
- Removes all components from this vector and sets its size to zero.
boolean removeElement(Object obj)
- Removes the first (lowest-indexed) occurrence of the argument from this vector.
void removeElementAt(int index)
- Deletes the component at the specified index.
import java.util.Vector;
public class Main{
public static void main(String args[]) {
Vector v = new Vector();
v.add("java2s.com");
v.add("java2s.com");
v.add("java2s.com");
v.remove(0);
System.out.println(v);
}
}
The output:
[java2s.com, java2s.com]
Home
Java Book
Collection
Java Book
Collection
Vector:
- Vector class
- Create Vector objects
- Add elements to this vector
- Size and capacity
- Remove all elements from a vector
- Clone a vector
- Does it contain a certain element
- Copy elements in vector to an array
- Get Enumeration from this vector
- Compare two vectors
- Get element from vector
- Is vector empty
- Get element index
- Remove element from a vector
- Retain elements collection c has
- Replace element in a vector
- Get a sub list from a list
- Convert Vector to Array