Get element from vector
E elementAt(int index)
- Returns the component at the specified index.
E firstElement()
- Returns the first component (the item at index 0) of this vector.
E get(int index)
- Returns the element at the specified position in this Vector.
E lastElement()
- Returns the last component of the vector.
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Vector;
public class Main{
public static void main(String args[]) {
Vector v = new Vector();
v.add("java2s.com 1");
v.add("java2s.com 2");
v.add("java2s.com 3");
System.out.println(v.elementAt(2));
}
}
The output:
java2s.com 3
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