Online Java Compiler By
JavaTpoint.com
//Program to illustrate the lastElement() method import java.util.*; public class VectorLastElementExample1 { public static void main(String arg[]) { //Create an empty vector Vector
vec = new Vector<>(4); //Add elements in the vector vec.add("Java"); vec.add("JavaScript"); vec.add("Android"); vec.add("Python"); //Obtain the last element of this vector System.out.println("The last element of a vector is: " +vec.lastElement()); } }
Output