Vector


Vector

It is a linear data structure which can be used to store collection of objects. The 2 important operations performed are push and pop. It follows Last In First Out (LIFO) order. It extends the vector class.

Syntax:

Vector obj = new Vector(size, increment);

Example :

Com.knowledge2life import java.util.*; public class Main { public static void main(String args[]) { Vector<String> vec = new Vector<String>(); vec.add("Knowledge2life 1"); vec.add("Knowledge2life 2"); vec.addElement("Knowledge2life 3"); vec.addElement("Knowledge2life 4"); System.out.println("Website are: "+vec); } }

OUTPUT:

Website are: [Knowledge2life 1, Knowledge2life 2, Knowledge2life 3, Knowledge2life 4]