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<String> v = new Vector<String>(); 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