- Java.util - Home
- Java.util - ArrayDeque
- Java.util - ArrayList
- Java.util - Arrays
- Java.util - BitSet
- Java.util - Calendar
- Java.util - Collections
- Java.util - Currency
- Java.util - Date
- Java.util - Dictionary
- Java.util - EnumMap
- Java.util - EnumSet
- Java.util - Formatter
- Java.util - GregorianCalendar
- Java.util - HashMap
- Java.util - HashSet
- Java.util - Hashtable
- Java.util - IdentityHashMap
- Java.util - LinkedHashMap
- Java.util - LinkedHashSet
- Java.util - LinkedList
- Java.util - ListResourceBundle
- Java.util - Locale
- Java.util - Observable
- Java.util - PriorityQueue
- Java.util - Properties
- Java.util - PropertyPermission
- Java.util - PropertyResourceBundle
- Java.util - Random
- Java.util - ResourceBundle
- Java.util - ResourceBundle.Control
- Java.util - Scanner
- Java.util - ServiceLoader
- Java.util - SimpleTimeZone
- Java.util - Stack
- Java.util - StringTokenizer
- Java.util - Timer
- Java.util - TimerTask
- Java.util - TimeZone
- Java.util - TreeMap
- Java.util - TreeSet
- Java.util - UUID
- Java.util - Vector
- Java.util - WeakHashMap
- Java.util - Interfaces
- Java.util - Exceptions
- Java.util - Enumerations
- Java.util Useful Resources
- Java.util - Useful Resources
- Java.util - Discussion
java.util.Vector.remove() Method
Description
This remove(Object o) method is used to remove the first occurrence of the specified element in this Vector.If the Vector does not contain the element it remains unchanged.
Declaration
Following is the declaration for java.util.Vector.remove() method
public boolean remove(Object o)
Parameters
o − This is the element to be removed from this Vector, if present.
Return Value
The method call returns true if the Vector contained the specified element.
Exception
NA
Example
The following example shows the usage of java.util.Vector.remove() method.
package com.tutorialspoint;
import java.util.Vector;
public class VectorDemo {
public static void main(String[] args) {
// create an empty Vector vec with an initial capacity of 6
Vector<Integer> vec = new Vector<Integer>(6);
// use add() method to add elements in the vector
vec.add(33);
vec.add(34);
vec.add(22);
vec.add(11);
vec.add(22);
vec.add(12);
// let us remove the 1st element
System.out.println("Removed element: "+vec.remove((Integer)22));
// lets print the elements
System.out.println("The elements in the vector are:");
for (Integer number : vec) {
System.out.println("Number = " + number);
}
}
}
Let us compile and run the above program, this will produce the following result.
Removed element: true The elements in the vector are: Number = 33 Number = 34 Number = 11 Number = 22 Number = 12
java_util_vector.htm
Advertisements