import java.util.Vector; public class Example { public static void main(String[] args) { Vectorvec = new Vector (); vec.add(10); vec.add(20); vec.add(30); vec.add(40); if(vec.contains(20)) { System.out.println("Vector contains 20."); } else { System.out.println("Vector does not contain 20."); } } }
import java.util.Vector; public class Example { public static void main(String[] args) { VectorIn this example, we create a Vector of string values and use the contains() method to check if it contains the value "mango". Since "mango" is not present in the Vector, the output will be "Vector does not contain mango." The Vector class is a part of the java.util package library.vec = new Vector (); vec.add("apple"); vec.add("banana"); vec.add("orange"); vec.add("grape"); if(vec.contains("mango")) { System.out.println("Vector contains mango."); } else { System.out.println("Vector does not contain mango."); } } }