10:42 am - Thursday January 19, 2017

Vector Example Program for contains(Object o)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

// Vector Example Program for contains(Object o)
/**
@author: candidjava.com
@description: This program returns "true" if the vector contains the specified element otherwise returns false.
*/

import java.util.*;

public class Contains {
public static void main(String[] args) {
Vector v = new Vector(3); // New Vector of size 3 is created
// adding 3 elements to the Vector
v.add(3);
v.add(5);
v.add(8);

boolean b = v.contains(2); // Returns true if the vector contains 2,
// else returns false
System.out.println(b);
boolean b1 = v.contains(5); // Returns true if the vector contains 5,
// else returns false
System.out.println(b1);
}
}

output:
false
true

Filed in: Z-A All Java Codes

Comments are closed.