Mega Code Archive
 
 
    
Getting by Position
The firstElement() and lastElement(): get the element at position 0 and 
also at the end (position size-1).
 
public Object firstElement()
public Object lastElement() 
 
import java.util.Vector;
public class MainClass {
  public static void main(String args[]) {
    Vector v = new Vector();
    v.add("A");
    v.add("B");
    String firstElement = (String) v.firstElement();
    String lastElement = (String) v.lastElement();
    System.out.println(firstElement);
    System.out.println(lastElement);
  }
} 
A
B